Simple BV Question

spg2112

Active Member
Joined
Feb 27, 2002
Messages
316
Hello again,

OK, what's wrong with this code? I just want to select a range that = E3 to the value thats in A1.

Sub GetAU()
Dim a As Variant
a = Sheets("Data").Range("A1").Value

Sheets("Data").Range("E3").Select
Range(Selection, Selection.Offset(0, a)).Select


End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Not sure what you're saying here. Could you try to rephrase your question. What you're trying to do sounds simple enough though.
 
Upvote 0
The value in A1 is just a record count. I want to select the range from E3 to the bottom of the data. If A1 = 500, I want to select E3:E500, plus one or 2 rows for headers and such.

Steve
 
Upvote 0
You could try the following:

Code:
Sub GetAU2()
Dim a As Integer
a = Sheets("data").[A1].Value
Sheets("data").Range("E3:E" & a).Select
End Sub
You change e3 to e1 for headers, etc...and a to a+2 for footers, etc...Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-26 09:24
 
Upvote 0
Good repost.

Follow Nate's solution. (Although I'm a picky bstart, so I'd change that "Dim a as Integer" to "Dim a as Long" since there are more than 32,767 rows in Excel)
 
Upvote 0
You're welcome SPG. Good point Mark! And one wouldn't have to be so picky if Xl herself wasn't so :)
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top