Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    vlookup inside of macro (how to expand?) (Excel 97 SR-1)

    I've created a macro to do a number of things...at the end it does a vlookup. I've gotten the vlookup to work fine. The number of rows in the file constantly change (1 day there may be 500, one day there may be 613). How do I adjust the macro for the change contingency...in other words, if on the first day, my file has 500 rows, I want it to do a vlookup on 500 rows...the second day, it has 502 rows, I want it to do a vlookup on 502 rows. Can anybody help?

    Adam Roehm
    aroehm@skynexx.net

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vlookup inside of macro (how to expand?) (Excel 97 SR-1)

    In ordre to help, we would need to see the macro, and have some description of how to determine how many rows need to be searched.
    Legare Coleman

  3. #3
    Lounger
    Join Date
    Oct 2001
    Location
    Isleworth, Gtr London, England
    Posts
    28
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: vlookup inside of macro (how to expand?) (Excel 97 SR-1)

    It sounds as if a dynamic defined name for your look-up range will do the trick.

    In the worksheet, use menu command Insert/Name/Define, and choose a name for the range containing all the values, e.g. LookList, and then in the Refers To box type this formula:
    =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),5)
    or something similar ( this formula is for sheet Sheet1, and for a look-up range containing only 5 columns ).

    The COUNTA function counts all non-blank entries in column A, and then the OFFSET function creates a range the same length as the count, and a wide as is necessary ( 5 in this case ).

    Then you can use the name LookList in your VLOOKUP, so that the correct range is used every time.

    Hope that helps.
    Glenn.

Posting Permissions

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