ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Vlookup Error (https://www.excelbanter.com/excel-discussion-misc-queries/206665-vba-vlookup-error.html)

Skip Bisconer

VBA Vlookup Error
 
In Excell 2007 I am formating an imported CSV file of credit card
transactions into and existing workbook. I used the foloowing code to place a
lookup in column B:

Sheets(1).Range("B2").Formula = "=(VLOOKUP(A2,GLCode,2,"")"

This works perfectly and further down in the code it is placed in all the
cells in B:B to the end of transactions. The problem for me is that A:A in
the onset is blank so the lookup returns #NA, whic is expected. But i parse
these lines of data out into separate worksheets from Access and email then
to each individual cardholder for their input intl column A:A. Outside of VBA
I would use IFERROR(Vlookup,"") and be on my way but I cannot get this to
work in code.

The following code is my unsucessful attempt that gives me an
Application-defined or Object-defined Error 1004 halt. I just can't figure
where to put Application. at and make I work.

Sheets(1).Range("B2").Formula = "=IFERROR(VLOOKUP(A2,GLCode,2,"")"

Any suggestions would be helpful


--Skip
Using Office 2003 Pro
2007 Student version

Mike H

VBA Vlookup Error
 
Try this

Sheets(1).Range("B2").Formula =
"=IF(ISNA(VLOOKUP(A2,GlCode,2)),"""",VLOOKUP(A2,Gl Code,2))"

Mike

"Skip Bisconer" wrote:

In Excell 2007 I am formating an imported CSV file of credit card
transactions into and existing workbook. I used the foloowing code to place a
lookup in column B:

Sheets(1).Range("B2").Formula = "=(VLOOKUP(A2,GLCode,2,"")"

This works perfectly and further down in the code it is placed in all the
cells in B:B to the end of transactions. The problem for me is that A:A in
the onset is blank so the lookup returns #NA, whic is expected. But i parse
these lines of data out into separate worksheets from Access and email then
to each individual cardholder for their input intl column A:A. Outside of VBA
I would use IFERROR(Vlookup,"") and be on my way but I cannot get this to
work in code.

The following code is my unsucessful attempt that gives me an
Application-defined or Object-defined Error 1004 halt. I just can't figure
where to put Application. at and make I work.

Sheets(1).Range("B2").Formula = "=IFERROR(VLOOKUP(A2,GLCode,2,"")"

Any suggestions would be helpful


--Skip
Using Office 2003 Pro
2007 Student version



All times are GMT +1. The time now is 11:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com