Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: Simple BV Question

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Dallas, TX
    Posts
    316
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Dallas, TX
    Posts
    316
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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, NateO

    [ This Message was edited by: NateO on 2002-04-26 09:24 ]

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Dallas, TX
    Posts
    316
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Nato, that will work!

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #7
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You're welcome SPG. Good point Mark! And one wouldn't have to be so picky if Xl herself wasn't so

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •