+ Reply to Thread
Results 1 to 12 of 12

Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction class

  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction class

    Experimenting with Vlookup function in VBA and not getting a result with the code below. The problem seems to be in the "Sub cboLocation"...pointing to the Vlookup formula itself.


    Private Sub cboLocation_AfterUpdate()
    Dim LookupLists As Sheets
    Dim cboLocation As ComboBox
    Dim txtAppID As TextBox
    Dim UserVLookup As Workbooks

    Me.txtAppID.Value = WorksheetFunction.VLookup(Trim(Me.cboLocation.Value), Workbooks("UserVLookup").Sheets("LookupLists").Range("A1:H13").Value, 3, False)

    End Sub


    Private Sub UserForm_Initialize()
    Dim cLoc As Range
    Dim ws As Worksheet
    Set ws = Worksheets("LookupLists")

    For Each cLoc In ws.Range("Vvalue")
    With Me.cboLocation
    .AddItem cLoc.Value
    End With
    Next cLoc
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Workbooks("UserVLookup").Sheets("LookupLists").Range("A1:H13").Value

    Is that the name of the workbook including the file extension (as seen in the workbook's title bar) and is the workbook opened?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    That is the name without the file extension and it's the only open workbook... i'll try with the extension

  4. #4
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    No luck even with the extension (.xlsm).

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    If it's the only workbook, you could omit the workbook reference.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    I tried the new code without any reference to the workbook and the same error 1004 shows itself.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Remove the .Value property from...
    Sheets("LookupLists").Range("A1:H13").Value

  8. #8
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    I thought that this is it...but it's a no go. Same error.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Show the code you have now with the changes.

  10. #10
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Private Sub cboLocation_AfterUpdate()
    Dim LookupLists As Sheets
    Dim cboLocation As ComboBox
    Dim txtAppID As TextBox

    Me.txtAppID.Value = WorksheetFunction.VLookup(Trim(Me.cboLocation.Value), Sheets("LookupLists").Range("A1:H13"), 3, False)

    End Sub


    Private Sub UserForm_Initialize()
    Dim cLoc As Range
    Dim ws As Worksheet
    Set ws = Worksheets("LookupLists")

    For Each cLoc In ws.Range("Vvalue")
    With Me.cboLocation
    .AddItem cLoc.Value
    End With
    Next cLoc
    End Sub

  11. #11
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    Your code works for me. Not sure why the VLookup errors for you. Here's another way to do it.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-22-2013
    Location
    Edina, MN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Run-time erro '1004': Unable to get the Vlookup property of the WorksheetFunction clas

    Thank you very much. I don't understand how the code works yet but it works. You save me from a lot of beginner's headaches.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Run - time error '1004': Unable to get the Sum property of WorksheetFunction class
    By dylanrose in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 10:25 AM
  2. Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class
    By sridhar_neel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2012, 04:21 AM
  3. Run-time error '1004': Unable to get the Match property of Worksheetfunction class
    By krish T in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2010, 10:04 PM
  4. Run-time error 1004: Unable to get the Match property of the WorksheetFunction class
    By maffmommie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2010, 09:32 AM
  5. run-time error '1004 Unable to get Match property of WorksheetFunction class
    By exl044 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2010, 02:23 AM

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