0

I'm trying to call a range between a fixed cell and a dynamic cell (which i can reference using a defined name and an offset). Im not too sure how the syntax should go. Currently I have:

Range("B21:Range("Anchor").Offset(-1,1)")
'(i know this is incorrect syntax, but just to show you the logic)

Where B21 is the fixed cell. And "Anchor" is the Defined name which has a dynamic cell address.

For some background: I'm trying to call all cells within a column of a table, however the table has an "add rows" function, so the last cell of the column is always changing. My "Anchor" is below the position the last row will be.

Im not very good with VBA language, so please bear with me.

1 Answer 1

1

You can do it like this:

Dim ws as worksheet, rng as range

set ws = activesheet

With ws
    Set rng = .Range(.Range("B21"), .Range("Anchor").Offset(-1,1))
end with
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That fixed it!

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.