Viktor Zafirovski
Viktor Zafirovski

Reputation: 437

Excel VBA: Runtime Error 424, Object Required

I can't figure this issue out. I had a similar problem before, it turned out I was using a Range of a single cell, which was redundant. But in this case I need End(xlDown) and I can't get it to work. I tried a few combinations and I can't figure out the right syntax. Help?

Public Exceptions As Range
Public Xcept As Range

Sub Example()
Static ExcSh As Worksheet
Set ExcSh = Worksheets("ComboExceptions")
Set Exceptions = ExcSh.Range("A2")

Set Xcept = ExcSh.Range(Exceptions.Offset(1).Cells, Exceptions.Offset(1).Cells.End(xlDown))
'This is where the error happens ^
End Sub

Upvotes: 0

Views: 319

Answers (1)

Viktor Zafirovski
Viktor Zafirovski

Reputation: 437

Solved it! I had declared

Static ExcSh As Worksheet

in another Sub making it inaccessible to the function that errored. I made it public and now the following command works fine:

Set Xcept = ExcSh.Range(Exceptions.Offset(1), Exceptions.Offset(1).End(xlDown))

Upvotes: 1

Related Questions