View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
prahz prahz is offline
external usenet poster
 
Posts: 18
Default Using Vlookup in VBA

In excel I have created a user form, in which there is a label
("nonfincalcLabel"). I am trying to change the Caption of the label
based on a calculation using Vlookup when a change is made to one of
the comboboxes. The lookup table range is defined as "nonfinRange" in
the worksheet "nonfinTable".

When i try to run the code it says, Run-time error '1004': Unable to
get the Vlookup property of the WorksheetFunction class. Below is my
code, where am i going wrong?

Private Sub defaulthistoryCombo_Change()
Dim searchRange As Range

Set searchRange = Worksheets("nonfinTable").Range("nonfinRange")

nonfincalcLabel.Caption =
Application.WorksheetFunction.VLookup(xCombo.Value , searchRange, 3,
False) + Application.WorksheetFunction.VLookup(yCombo.Value ,
searchRange, 5, False)

End Sub