Results 1 to 7 of 7

Thread: VBA VLookup Function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2012
    Posts
    14
    Location

    VBA VLookup Function

    Hi,
    Im having trouble implementing a VLookup function into a macro. My Code:

    VBA:
    [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[/VBA]


    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.
    Last edited by Bob Phillips; 04-24-2012 at 06:25 AM. Reason: Added VBA tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •