Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Using a variable to select a row index in excel.

I'm sure this is unbelievably simple, but can anyone tell me how to use a variable to select a row in an excel macro.

e.g If I want to select rows 2 and 3 then I would write

Rows("2:3").Select

What I want is to be able to replace the 2 and 3 with a and b (where a is 2 and b is 3).

Thanks

Stuart
0
StuartL
Asked:
StuartL
1 Solution
 
TimCotteeHead of Software ServicesCommented:
Dim a As String
Dim b As String
a = "2"
b = "3"
Rows(a & ":" & b).Select
0
 
StuartLAuthor Commented:
That works great, thanks.  I just couldn't find out the format of the (a&.. bit.

Cheers

Stuart
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now