+ Reply to Thread
Results 1 to 6 of 6

Dynamically adjusting Vlookup

  1. #1
    Registered User
    Join Date
    07-25-2005
    Posts
    4

    Dynamically adjusting Vlookup

    Hi,

    At work we often paste multiple reports into excel. These reports are always different sizes. I've created a search function which allows me to to identify exactly where the report has been pasted. The function also gathers information about where the report starts and stops. The problem I'm having is being able to use variables within the Vlookup function within Excel.

    This is what I would like to do:


    Dim Column1 as interger
    Dim row1 as interger
    Dim Column2 as interger
    Dim row2 as interger
    Dim Column3 as interger
    Dim row3 as interger

    {Program then assigns values to these varibles based upon the search conducted.}

    then this is what I can't figure out:

    What's the syntax for passing my varibles into the vlookup function?

    ' I've tried this, and it doesn't work.

    =vlookup(cells(row1, column1), cells(row2, column2):cells(row3, column3),9,false)

    How come this won't work?

    What I'm hoping to achieve is a dynamically adjusting vlookup field based upon the inputs from the variables, but I can't seem to get the syntax correct.


    Any help would be greatly appreciated!!



    Thanx,


    Angusrocks.

  2. #2
    Barb Reinhardt
    Guest

    Re: Dynamically adjusting Vlookup

    Look at the ADDRESS function and see if that does what you want.
    Barb Reinhardt
    "angusrocks" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hi,
    >
    > At work we often paste multiple reports into excel. These reports are
    > always different sizes. I've created a search function which allows me
    > to to identify exactly where the report has been pasted. The function
    > also gathers information about where the report starts and stops. The
    > problem I'm having is being able to use variables within the Vlookup
    > function within Excel.
    >
    > This is what I would like to do:
    >
    >
    > Dim Column1 as interger
    > Dim row1 as interger
    > Dim Column2 as interger
    > Dim row2 as interger
    > Dim Column3 as interger
    > Dim row3 as interger
    >
    > {Program then assigns values to these varibles based upon the search
    > conducted.}
    >
    > then this is what I can't figure out:
    >
    > What's the syntax for passing my varibles into the vlookup
    > function?
    >
    > ' I've tried this, and it doesn't work.
    >
    > =vlookup(cells(row1, column1), cells(row2, column2):cells(row3,
    > column3),9,false)
    >
    > How come this won't work?
    >
    > What I'm hoping to achieve is a dynamically adjusting vlookup field
    > based upon the inputs from the variables, but I can't seem to get the
    > syntax correct.
    >
    >
    > Any help would be greatly appreciated!!
    >
    >
    >
    > Thanx,
    >
    >
    > Angusrocks.
    >
    >
    > --
    > angusrocks
    > ------------------------------------------------------------------------
    > angusrocks's Profile:
    > http://www.excelforum.com/member.php...o&userid=25583
    > View this thread: http://www.excelforum.com/showthread...hreadid=390061
    >




  3. #3
    Rowan
    Guest

    RE: Dynamically adjusting Vlookup

    Try it like this:

    ActiveCell.Formula = "=VLOOKUP(" & Cells(row1, column1).Address & "," _
    & Range(Cells(row2, column2), Cells(row3, column3)).Address & ",9,0)"

    PS you should Dim the row variables as Long and not integer or you will get
    an overflow error if you go over 32,767 rows.

    Hope this helps
    Rowan

    "angusrocks" wrote:

    >
    > Hi,
    >
    > At work we often paste multiple reports into excel. These reports are
    > always different sizes. I've created a search function which allows me
    > to to identify exactly where the report has been pasted. The function
    > also gathers information about where the report starts and stops. The
    > problem I'm having is being able to use variables within the Vlookup
    > function within Excel.
    >
    > This is what I would like to do:
    >
    >
    > Dim Column1 as interger
    > Dim row1 as interger
    > Dim Column2 as interger
    > Dim row2 as interger
    > Dim Column3 as interger
    > Dim row3 as interger
    >
    > {Program then assigns values to these varibles based upon the search
    > conducted.}
    >
    > then this is what I can't figure out:
    >
    > What's the syntax for passing my varibles into the vlookup
    > function?
    >
    > ' I've tried this, and it doesn't work.
    >
    > =vlookup(cells(row1, column1), cells(row2, column2):cells(row3,
    > column3),9,false)
    >
    > How come this won't work?
    >
    > What I'm hoping to achieve is a dynamically adjusting vlookup field
    > based upon the inputs from the variables, but I can't seem to get the
    > syntax correct.
    >
    >
    > Any help would be greatly appreciated!!
    >
    >
    >
    > Thanx,
    >
    >
    > Angusrocks.
    >
    >
    > --
    > angusrocks
    > ------------------------------------------------------------------------
    > angusrocks's Profile: http://www.excelforum.com/member.php...o&userid=25583
    > View this thread: http://www.excelforum.com/showthread...hreadid=390061
    >
    >


  4. #4
    Registered User
    Join Date
    07-25-2005
    Posts
    4

    Smile Dynamic VLookup

    Thank you Barb,


    I'll try what you have suggested and post a reply as to my results.



    Oh, and I know about declaring the variables as longs.... I was just in a hurry typing up my question.


    Thanks again.




    Angusrocks.

  5. #5
    Registered User
    Join Date
    07-25-2005
    Posts
    4

    Dynamic VLookup

    Oh Thanks to Rowan too.


    Being in a hurry is always gonna get me!!


    Angusrocks.

  6. #6
    Registered User
    Join Date
    07-25-2005
    Posts
    4

    Dynamic VLookup

    Thank you so much!!


    It works!


    This is gonna save me and 5 other analysts so much time.



    Thanks again.



    Angusrocks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1