View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JimFor JimFor is offline
external usenet poster
 
Posts: 31
Default VBA VLOOKUP AND No Value Match

Hi,

I'm working on a program which uses the VLOOKUP function. I have some account
numbers on one sheet (Sheet2) and want to see if there are correspoding
inventory amounts on another sheet(Sheet1). Things work OK if there are
inventory amounts. These numbers are placed next to the proper account number
on Sheet2. However, in some cases the an account number found on Sheet2 is not
found on Sheet1. . In that case, I want to leave the cell on Sheet2 next to
an account number which does appear on Sheet1 blank. Nothing will appear in
it. So far, I have been unable to do this. Here is a bit of my program.

Sub ZOO()

Cells(5, 8) = WorksheetFunction.VLookup(ActiveSheet.Range("A2"), _
Worksheets("Sheet1").Range("A2:C4"), 2, 0)
End Sub

From what I have read, I have to replace the last zero with the word "FALSE"
and use an IF(ISNA...code to do what I want. I first tried the putting a
"FALSE" in the program, which, I believe, should have placed "N/A" next to any
account which did not have an inventory amount on sheet 1. That does not work.
When I put in an account number in Sheet2 which is not on Sheet1 and run the
program, I do not get a "FALSE" on Sheet 2 but an error message "400." I
stopped there and have not attempted to include the "IF(ISNA..." code in the
VLOOKUP function. Can anyone tell me what I have done wrong and how I can get
the VLOOKUP to put a blank in a cell in Sheet2 next to an account number if the
program cannot find that account number on Sheet 1?

Thanks