Is it possible to use the Vlookup command in VB. The reason is that I want a value entered and then the lookup function performed to enter data into the required sheet. This is so that I don't have formulas in the sheet itself.
I have tried doing it in VB with the same syntax as I would in a worksheet but get an error: sub or function not defined (with VLookup highlighted)
Here is the Code:
Sub AddTask_Click()
'
' AddTask_Click Macro
' Macro recorded 09/10/2006 by BoB
'
Dim Username As String
Dim Firstname As String
Dim Lastname As String
Dim Centre As String
Dim Course As String
Username = Range("E3")
Course = Range("E5")
If Username = "" Then
MsgBox "Please Enter a Username"
ElseIf Course = "" Then
MsgBox "Please Enter a Course"
Else
Firstname = VLookup(Username, Jungle, 3, False)
Lastname = VLookup(Username, Jungle, 4, False)
Centre = VLookup(Username, Jungle, 2, False)
InsertLine
Range("TaskList!B5") = Firstname
Range("TaskList!B6") = Lastname
Range("TaskList!B7") = Centre
Range("TaskList!B8") = Course
End If
Sheets("Front").Select
Range("E3") = Null
Range("E5") = Null
Range("E3").Select
End Sub
Thanks in advance
Bookmarks