Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default #NA error using vlookup in vba

Hi
I have the following formual in VBA and I keep getting the #NA in the ouput
cell and I dont know why.

Dim stNumber As String
Dim stans As Variant

stNumber = cobStore.Value
stans = Application.VLookup(stNumber,
Worksheets("Numbers").Range("A2:B188"), 2)

Range("I15").Value = stans

can someone please help.

Thanks
Noemi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default #NA error using vlookup in vba

Perhaps we need to tell excel what cobstore is?
Sub lookitup()
cobstore = 1
Range("I15") = Application.VLookup(cobstore, _
Worksheets("sheet4").Range("d2:e188"), 2)
End Sub

--
Don Guillett
SalesAid Software

"Noemi" wrote in message
...
Hi
I have the following formual in VBA and I keep getting the #NA in the

ouput
cell and I dont know why.

Dim stNumber As String
Dim stans As Variant

stNumber = cobStore.Value
stans = Application.VLookup(stNumber,
Worksheets("Numbers").Range("A2:B188"), 2)

Range("I15").Value = stans

can someone please help.

Thanks
Noemi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default #NA error using vlookup in vba

stNumber

would indicate that you are looking up a number, but you have typed stNumber
as String.

the string "123" does not match the number 123. So if your search range
contains numbers, you need to search with a number.

Perhaps do

Dim stNumber As Double

--
Regards,
Tom Ogilvy

"Noemi" wrote in message
...
Hi
I have the following formual in VBA and I keep getting the #NA in the

ouput
cell and I dont know why.

Dim stNumber As String
Dim stans As Variant

stNumber = cobStore.Value
stans = Application.VLookup(stNumber,
Worksheets("Numbers").Range("A2:B188"), 2)

Range("I15").Value = stans

can someone please help.

Thanks
Noemi



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default #NA error using vlookup in vba

Hi Tom
Thank you very much, that was the problem. It should have been double.
Thanks again
Noemi

"Tom Ogilvy" wrote:

stNumber

would indicate that you are looking up a number, but you have typed stNumber
as String.

the string "123" does not match the number 123. So if your search range
contains numbers, you need to search with a number.

Perhaps do

Dim stNumber As Double

--
Regards,
Tom Ogilvy

"Noemi" wrote in message
...
Hi
I have the following formual in VBA and I keep getting the #NA in the

ouput
cell and I dont know why.

Dim stNumber As String
Dim stans As Variant

stNumber = cobStore.Value
stans = Application.VLookup(stNumber,
Worksheets("Numbers").Range("A2:B188"), 2)

Range("I15").Value = stans

can someone please help.

Thanks
Noemi




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vlookup error SDMFG Excel Worksheet Functions 2 March 25th 09 08:31 PM
VLOOKUP #N/A Error NM Excel Worksheet Functions 7 November 13th 08 09:41 PM
Vlookup Error #N/A Abdul Excel Discussion (Misc queries) 4 November 4th 08 12:45 PM
vlookup error Vlookup not accurate Excel Discussion (Misc queries) 9 October 5th 06 04:06 PM
VLOOKUP error Mr. Boyer Excel Worksheet Functions 3 May 19th 06 04:50 PM


All times are GMT +1. The time now is 10:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"