+ Reply to Thread
Results 1 to 3 of 3

Storing vlookup as variable in VBA

  1. #1
    Registered User
    Join Date
    08-05-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    36

    Storing vlookup as variable in VBA

    Hello all,

    I'm looking to store different values to a variable that would be holding a vlookup function. I'm storing the variable as a double, but one of the criteria that my macro checks is to make sure that the vlookup is actually succesful, (i.e. if iserror(application.vlookup(BLAHBLAH)) then).

    Here's the example I'm talking about:

    Please Login or Register  to view this content.
    Is this something that is allowed in VBA? Do I have to declare the variable as a certain type?

    Any help would be great. Thank you very much

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Storing vlookup as variable in VBA

    If I understand correctly, I think you have to declare it As Variant.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Storing vlookup as variable in VBA

    Your code isn't doing what you think. It's doing the lookup once, prior to the loop, and then using the result repeatedly.
    Entia non sunt multiplicanda sine necessitate

+ 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