Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VLOOKUP and Missing Values

Hi,

Working on a program which has last period inventory totals by account on sheet
1 and current period transactions (sales and purchases) on sheet 2. Sheet 3
will have beginning inventory amounts by accounts (among other things). I use
the VLOOKUP in VBA to determine the beginning inventory amounts for each
account I have transactions for. Works OK but I do not know what to do if
sheet 2 has some accounts which have no corresponding last period inventory
totals on sheet 1, i.e., their account numbers do no appear on sheet 1. I
get an "N/A" in a cell on sheet 3 in the column which contains other values
received from the VLOOKUP and the program stops. . Can anyone tell me how to
set up the VLOOKUP to enter a zero in a cell if it does not find an account
number on sheet 1? I need to do this because I will have to do some
calculations with that number for that account. Here is the line of programming
I use:.

Worksheets("Sheet3").Cells(Kook, 10) = Application.VLookup(Sheet2.Cells(Count,
3), _
Worksheets("Sheet1").Range("A2:B9"), 2, 0)

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VLOOKUP and Missing Values

Dim res as Variant
res = Application.VLookup(Sheet2.Cells(Count,3), _
Worksheets("Sheet1").Range("A2:B9"), 2, 0)
if iserror( Res) then
Worksheets("Sheet3").Cells(Kook, 10) = 0
Else
Worksheets("Sheet3").Cells(Kook, 10) = res
End if

--
Regards,
Tom Ogilvy


"JimFor" wrote in message
...
Hi,

Working on a program which has last period inventory totals by account on

sheet
1 and current period transactions (sales and purchases) on sheet 2. Sheet

3
will have beginning inventory amounts by accounts (among other things). I

use
the VLOOKUP in VBA to determine the beginning inventory amounts for each
account I have transactions for. Works OK but I do not know what to do if
sheet 2 has some accounts which have no corresponding last period

inventory
totals on sheet 1, i.e., their account numbers do no appear on sheet 1.

I
get an "N/A" in a cell on sheet 3 in the column which contains other

values
received from the VLOOKUP and the program stops. . Can anyone tell me how

to
set up the VLOOKUP to enter a zero in a cell if it does not find an

account
number on sheet 1? I need to do this because I will have to do some
calculations with that number for that account. Here is the line of

programming
I use:.

Worksheets("Sheet3").Cells(Kook, 10) =

Application.VLookup(Sheet2.Cells(Count,
3), _
Worksheets("Sheet1").Range("A2:B9"), 2, 0)

Thanks



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 returns n/a for all lines - what am I missing? Lorina Excel Worksheet Functions 3 November 10th 09 05:38 PM
vlookup missing link Enrique Excel Discussion (Misc queries) 2 January 30th 07 06:17 PM
missing values Arne Hegefors Excel Discussion (Misc queries) 1 January 11th 07 11:12 AM
Missing values from SAS Mitch Excel Worksheet Functions 4 March 14th 06 07:22 PM
Excel Compare values in columns & display missing values in a new cpetta Excel Discussion (Misc queries) 1 April 2nd 05 05:51 AM


All times are GMT +1. The time now is 06:54 AM.

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

About Us

"It's about Microsoft Excel"