Andrew01
04-24-2012, 06:20 AM
Hi,
Im having trouble implementing a VLookup function into a macro. My Code:
VBA:
Private Sub cmdCalculate_Click()
Dim TimeInput As Date
Dim Stock As String
Dim Price As Double
Dim PercentageChange As Double
TimeInput = Range("A7")
Stock = Range("B7")
If Stock = "A" Then
Price = Application.WorksheetFunction.VLookup(TimeInput, Range("J15:V50"), 3, False)
MsgBox (Price)
ElseIf Stock = "B" Then
'Insert
ElseIf Stock = "C" Then
'Insert
ElseIf Stock = "D" Then
'Insert
End If
End Sub
I get the following error message when I click the button:
Runtime Error 1004:
Unable to get the VLookup Property of the Worksheet Function class.
Any Ideas would be greatly appreciated.
Cheers.
Im having trouble implementing a VLookup function into a macro. My Code:
VBA:
Private Sub cmdCalculate_Click()
Dim TimeInput As Date
Dim Stock As String
Dim Price As Double
Dim PercentageChange As Double
TimeInput = Range("A7")
Stock = Range("B7")
If Stock = "A" Then
Price = Application.WorksheetFunction.VLookup(TimeInput, Range("J15:V50"), 3, False)
MsgBox (Price)
ElseIf Stock = "B" Then
'Insert
ElseIf Stock = "C" Then
'Insert
ElseIf Stock = "D" Then
'Insert
End If
End Sub
I get the following error message when I click the button:
Runtime Error 1004:
Unable to get the VLookup Property of the Worksheet Function class.
Any Ideas would be greatly appreciated.
Cheers.