0

Ok, I'm sure this question is really basic but all my searchers turn up complicated answers and I've been messing with VBA for about a day. I have two worksheets in an excel doc, I've created a button that I can click that invokes my macro that is just moving cells from one work sheet to another. But I need my macro to determine what row I am on. I'm using this:

r = ActiveCell.Row

to determine my row, but what would be the easiest way to use that variable in a range statement like this:

Range("A2").Select
2
  • Please clarify what you're asking, though. The way I read is: "how do I select the row from the variable r?" but it's not clear that is really your question. Commented Feb 20, 2015 at 17:25
  • 1
    Stop using .select Commented Feb 20, 2015 at 18:35

1 Answer 1

8

You could use the Range method with the & operator to join the variable into a string:

Range("A" & r)

Alternately you can use the Cells method which takes arguments (Row, Column):

Cells(r, "A")
Sign up to request clarification or add additional context in comments.

Comments

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.