View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Buckner Bill Buckner is offline
external usenet poster
 
Posts: 4
Default VLookup function in VBA problem?

JWolf

That makes sense except in the same worksheet function call I use another variable "insurance" which is defined in the following code. So if your response is the reason I keep getting "type" errors, why does it work for some and not for others? Could the fact that one is a date and one is an integer have anything to do with my problem? Maybe the fact that I do some calculations on the variable "insurance" before it is sent to the worksheet function causes some type conversions to take place??

Dim insurance As Intege
Dim retireDate As Dat
insurance = Range("Insurance_Selection"
retireDate = CDate(Range("Retire_Date_Primary").Value

Application.VLookup(Range("Retire_Date_Primary"), Range("Pension_Table"), 21 + insurance - 1) '<= This work
Application.VLookup(retireDate , Range("Pension_Table"), 21 + insurance - 1) '<= This fail