Consulting

Results 1 to 2 of 2

Thread: VBA Combobox for vlookup

  1. #1
    VBAX Newbie
    Joined
    Jan 2018
    Posts
    1
    Location

    VBA Combobox for vlookup

    I'm getting an error with the following code. I would like to use the combobox to vlookup data on a sheet, then hit a submit button to change the information. Right now I'm getting an error just running a vlookup from the combobox.

    Private Sub LNameCombobox_Change()
    If Me.LNAMEComboBox.Value = "" Then Exit Sub
    PNTextBox.Value = Application.VLookup(Me.LNAMEComboBox.Value, Range("Sheet1!$B2:T10000"), 3, 0)
    End Sub

    The error is in line 3.

    Any help would be greatly appreciated.

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,191
    Location
    Shouldn’t:

    Range("Sheet1!$B2:T10000")

    Be

    Sheet1.Range("B2:T10000")

    hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

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