New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

vlookup

Macros, VBA, Excel Automation, etc.

vlookup

Postby laurensims41 » Fri Apr 29, 2016 9:36 am

I have a user form that I would like a user to input a 3 digit number into a text box and then lookup that number on a different sheet and then paste that value from the second sheet to a final sheet.

THis is the code I have so far and it is not working.

Code: Select all
Sheets("FinishedSheet").Cells(1,7)=Application.WorksheetFunction.Vlooup(tbsitenumber.value,Worksheets("OAM").Range("A9:M1500").Value,13)
.

tbsitenumber.value is the name of the text box on my form.

This command line keeps returning a run - time error of '1004;" Unalbe to get the VLookup property of the Worksheet Function Class.
  • 0

Last edited by laurensims41 on Fri Apr 29, 2016 11:53 am, edited 1 time in total.
laurensims41
Rookie
 
Posts: 15
Joined: Feb 3, 2016
Reputation: 0
Excel Version: Office Professional Plust 2010

Re: vlookup

Postby pecoflyer » Fri Apr 29, 2016 11:20 am

Please wrap code with tags - Thx
  • 0

A relevant topic title helps get faster and more answers
pecoflyer
Moderator
 
Posts: 1274
Joined: Jan 24, 2012
Location: Belgium
Reputation: 39
Excel Version: 2003/2007/2010

Re: vlookup

Postby NoSparks » Fri Apr 29, 2016 11:46 pm

  • 0

NoSparks
Excel Hobbyist
 
Posts: 637
Joined: May 28, 2014
Reputation: 103
Excel Version: 2010

Re: vlookup

Postby Sisyphus » Sun May 01, 2016 2:33 am

Perhaps it's just the typo in the function's name. Vlooup is missing a k.
Otherwise, look at the data type of the lookup value. Tbx.Value returns a string, even though it appears to be numeric. If you have numbers in column A, that could be the reason, and converting the Tbx.Value to a numeric value could be the cure.
As a matter of principle, I suggest splitting the final line of code into several components for testing purposes so that you can see where the error occurs. Start by testing the VLookup function on the worksheet. Then assign the Tbx.Value to a variable and issue the lookup to a MsgBox or Immediate Window. Once everything works fine you can put it back into a single line of code.
  • 0

Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 6 guests