1

I am looking to use variables to find a range as well as then use those to activate a selection.

Here is the code I have:

Dim first As Integer
Dim Last As Integer

first = (ActiveCell.Row + 1)
Selection.End(xlDown).Select
Last = (ActiveCell.Row - 1)
Range(("J" & first) : ("J" & last)).Select

However, I am getting a syntax error on this in Excel VBA 2010.

Any suggestions.

Thanks,

1 Answer 1

1

The Range syntax is Range("A1:B2") so you will need to modify your code to:

Dim first As Integer
Dim Last As Integer

first = (ActiveCell.Row + 1)
Selection.End(xlDown).Select
Last = (ActiveCell.Row - 1)
Range("J" & first & ":" & "J" & Last).Select
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Works perfect. Next part is how to use that in formula- posting on that now.

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.