0

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
3
  • 2
    Remove the two instances of .Cells Commented Feb 22, 2016 at 12:18
  • 1
    Is there a reason you just didn't start in A3 instead of A2 then .Offset(1) ? Commented Feb 22, 2016 at 12:24
  • There is, a very good reason yes. Either way, I solved it. Will post an answer right now. Commented Feb 22, 2016 at 12:25

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

1 Comment

As per @Jeeped comment above Set Xcept = ExcSh.Range(Exceptions, Exceptions.End(xlDown)) would also suffice if you adapt your starting point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.