![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Dallas, TX
Posts: 312
|
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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Not sure what you're saying here. Could you try to rephrase your question. What you're trying to do sounds simple enough though.
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Dallas, TX
Posts: 312
|
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 |
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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
_________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-26 09:24 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Dallas, TX
Posts: 312
|
Thanks Nato, that will work!
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
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) |
|
|
|
|
|
#7 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
You're welcome SPG. Good point Mark! And one wouldn't have to be so picky if Xl herself wasn't so
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|