I'm trying to build a function that will take an input cell (say "B5") and return a range object that refers to a table (of which the supplied cell is the top-right entry)
Sub Macro1()
Dim testCell As Range
testCell = Worksheets("HMA").Range("B5")
ReturnTable testCell
End Sub
Function ReturnTable(cell As Range)
firstcell = cell
lastrow = firstcell.End(x1Down)
Table = Range(firstcell, lastrow + 5).Value
End Function
I've been running into a lot of problems here, and I feel like I'm missing something simple. The error that I'm getting is "Object Required" at the lastRow line.
Looking through it in debug mode I see that testCell is assigned the value of the range object (I assume this is the default). What am I missing here?
Is my approach even sound? Should I be looking at solving this problem in a different way?
Setwhen assigning the value of testCell (or any other object variable), otherwise you're assigning the default property of the range (in this case.Value)