Compile Error: Sub or Function not Defined
Compile Error: Sub or Function not Defined
(OP)
Hi,
I am new to VBA programming and trying to write some code in VB editor of excel to look up table,find value and display in the TextBox on the userform.
I wrote the following code.But when I run it,it send me
Compile Error:
Sub or function not defined with Vlookup highlighted.
Could anyone tell me why?
[code]
Private Sub CommandButton1_Click()
TextBox1 = VLookup(1, "A2:B8", 2)
End Sub
Thanks,
I am new to VBA programming and trying to write some code in VB editor of excel to look up table,find value and display in the TextBox on the userform.
I wrote the following code.But when I run it,it send me
Compile Error:
Sub or function not defined with Vlookup highlighted.
Could anyone tell me why?
[code]
Private Sub CommandButton1_Click()
TextBox1 = VLookup(1, "A2:B8", 2)
End Sub
Thanks,





RE: Compile Error: Sub or Function not Defined
RE: Compile Error: Sub or Function not Defined
Try using the MACRO RECORDER, inserting the VLOOKUP in a cell, then edit the code as necessary.
----------------------------------
Hope this helps.
----------------------------------
maybe only a drafter
but the best user at this company!
RE: Compile Error: Sub or Function not Defined
RE: Compile Error: Sub or Function not Defined
cExlObject.WorksheetFunction.VLookup
RE: Compile Error: Sub or Function not Defined
Lesli
RE: Compile Error: Sub or Function not Defined
RE: Compile Error: Sub or Function not Defined
All the Excel-functions are in VBA also, all what you have to use is:
e.g.
Application.WorksheetFunction._
VLookup(X, Range("Vlookup_Range"), 2, False)
.:JJ:.