excel - Cannot return the address of a cell range from one function to another, I get an 'object required' error -
i 'object required' error when try return value of range 1 function function. read other answers 'object required' cannot figure out how relates code. forgive me i'm new vba. here's code:
function functionone() dim r range workbooks("workbook1.xls").activate sheets("sheet1").select set r = getrange("a1") application.goto r end function function getrange(strstart string) variant dim rng1 range dim rng2 range dim rng3 range set rng1 = cells.find("*", [a1], , , xlbyrows, xlprevious) set rng2 = cells.find("*", [a1], , , xlbycolumns, xlprevious) set rng3 = range([strstart], cells(rng1.row, rng2.column)) getrange = rng3.value end function
the 'object required' error happens @ set r = getrange("a1")
in functionone(). help.
change getrange
function return range
object:
function getrange(strstart string) range dim rng1 range dim rng2 range dim rng3 range set rng1 = cells.find("*", [a1], , , xlbyrows, xlprevious) set rng2 = cells.find("*", [a1], , , xlbycolumns, xlprevious) set rng3 = range([strstart], cells(rng1.row, rng2.column)) set getrange = rng3 end function
Comments
Post a Comment