View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lucile Lucile is offline
external usenet poster
 
Posts: 16
Default macro to find the closest value

Hi all,
I am writing a program with vba and I need your help!
I need to find the closest value to a value enter by the user.
I have load values in column C, the user enter a value for the load. I need
to find the closest value in columns C and the corresponding value of voltage
that is in column G.
I need to do that in a macro, I tried vlookup but it doesn't work.. give me
type mismatch.
Here is the piece of code...

tabledata = Range(Worksheets("data").Cells(1, "C"),
Worksheets("data").Cells(lastrow, "G"))
finfat = Application.VLookup(finalprefat, tabledata, "G", True)

finalprefat is enter by the user....

Thanks for your help!