View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default error 2042 with vlookup

Is the value in the cell with the 7 in it a real number or text?

Use
=isnumber(a1)
(change a1 to the correct cell address)

I'm not sure where you're getting X, but maybe you want to coerce it to number
before the =vlookup():
sz = Application.VLookup(clng(x), LC_Chars, 2, False)
or
sz = Application.VLookup(cdbl(x), LC_Chars, 2, False)



Bert wrote:

I have a named range ("LC_Chars"), and am trying to use the following code:
sz = Application.VLookup(x, LC_Chars, 2, False)
It is comparing a single character (x; in this case x="7", though the error
is generated no matter what the value of x.). The named range contains two
columns. The search column has been formatted as text and does contain a
"7".
The fix has to be simple, but I'm not seeing it.
Bert


--

Dave Peterson