+ Reply to Thread
Results 1 to 6 of 6

Vlookup assistance - getting Run-Time error '1004'

  1. #1
    Registered User
    Join Date
    01-29-2012
    Location
    Oregon
    MS-Off Ver
    Excel 2007
    Posts
    15

    Vlookup assistance - getting Run-Time error '1004'

    Hello and thanks for taking the time to read this....and hopefully provide some guidance

    I'm very new to writing Macros and am trying to use the Vlookup - this first attempt is just a test to see if I can get it to work.
    I have the range of A2:D367 named as: Useme
    Column A is a list of dates, starting A2 = 1/1/2012 through A367 = 12/31/12
    Column D lists the actual volume of transactions for that day.

    The goal (for this test) is to pick a date and have Excel return the volume for that date.

    Here is what I have:
    Please Login or Register  to view this content.
    If I omit the whole Vlookup part, the rest of the macro does correctly identify the proper row that holds the correct volume.
    With the Vlookup part added, I get the Run Time Error '1004'

    Any assistance would be greatly appreciated -
    Thank you in advance,
    Dan

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,477

    Re: Vlookup assistance - getting Run-Time error '1004'

    UseMe needs to be Range("UseMe")

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-29-2012
    Location
    Oregon
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Vlookup assistance - getting Run-Time error '1004'

    Thank you TMShucks - I changed the line to:
    Please Login or Register  to view this content.
    And I still get the same runtime error: 1004: Unable to get the Vlookup property of the WorksheetFunction class.

    I did double-check the range A2:D367 has the correct name of: Useme

    I've included a copy of the workbook I'm using.
    Attached Files Attached Files
    Last edited by dank_01; 07-30-2012 at 06:20 PM. Reason: Added sample workbook

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,477

    Re: Vlookup assistance - getting Run-Time error '1004'

    ?range("useme").Address
    $A$2:$D$367

    The VLOOKUP searches the leftmost column of the range and returns the value in the column designated, in this case, 4.

    You request a date, take out the day from it and add 1 ... for example, using your suggested date 15/07/2012 gives DayNum 197 and RowToUse 198. Sadly, it (the VLOOKUP) is not going to find 198 in a column of dates.

    You would need to use LOOKUP or INDEX/MATCH when the search column is not on the left hand side of the range

    Regards, TMS

  5. #5
    Registered User
    Join Date
    01-29-2012
    Location
    Oregon
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Vlookup assistance - getting Run-Time error '1004'

    Ahh - that makes sense. I'll try those options tomorrow. One question though - can I ignore the row number and have the Vlookup go just by the date?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,477

    Re: Vlookup assistance - getting Run-Time error '1004'

    Looking for a date in a range of dates would seem a reasonable approach. But I don't know why you were doing what you were doing ... it's your process.

    If looking for a date gives you what you need, way to go.

    Thanks for the rep.

    Regards, TMS


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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