Solved

Using a variable to select a row index in excel.

Posted on 2001-09-07
2
258 Views
Last Modified: 2012-06-21
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
Comment
Question by:StuartL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6463438
Dim a As String
Dim b As String
a = "2"
b = "3"
Rows(a & ":" & b).Select
0
 

Author Comment

by:StuartL
ID: 6463468
That works great, thanks.  I just couldn't find out the format of the (a&.. bit.

Cheers

Stuart
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question