Hey!

I some code similar to this:

Formula: copy to clipboard
Sub lastdatapoint()
Dim lastdatapoint As Long
Dim SheetName As Worksheet

Set SheetName = Worksheets("FB1")
lastdatapoint = Worksheets("SheetName").Cells(Rows.Count, 2).End(xlUp).Row

End Sub


And I get a "subscript out of range error" for this small excerpt, and with my other code, it doesn't seem to recognize the reference of lastdatapoint = Worksheets("SheetName"). So I'm wondering if my use of quotation marks is wrong? or maybe something else?

Any suggestions are VERY welcome!

Thanks in advance,

Dan