• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vlookup error

delta

Member
what is wrong in vlookup macro


TB2.Value = Application.WorksheetFunction.VLookup(TB1, Worksheets("BAZE").Range("K3:N10"), 2, 0)
TB3.Value = Application.WorksheetFunction.VLookup(TB1, Worksheets("BAZE").Range("K3:N10"), 3, 0)
 

Attachments

  • FORM - Copy (2).xlsm
    25.6 KB · Views: 8

Do not use WorksheetFunction but just Application !

Like Application.VLookup … And compare with a cell formula.​
 

The reason why WorksheetFunction crashes !

So first try a VLookup formula directly in a cell on Excel side …
As if it can't work in Excel, it can't work under VBA !
 
TB1 is object... you can't use TB1 as Lookup_Value.

Also, remember that Textbox & Combobox stores value as text only. So you should convert it to numeric value before using it in VLOOKUP.

Ex.
Code:
TB2.Value = Application.VLookup(CLng(TB1.Value), Worksheets("BAZE").Range("K3:N10"), 2, 0)
 
Back
Top