ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Vlookup error (https://www.excelbanter.com/excel-worksheet-functions/270920-vlookup-error.html)

wesley holtman

Vlookup error
 
Hello,

I've got a Vlookup formula that when I execute it, it totally changes
the lookup array. I entered the range "Cusip" as the lookup array in
the VBE but it shows up as "CorpA" in the spreadsheet. What am I doing
wrong?

VBE:

Corp.Range("BC4").Resize(DataRow, 1).FormulaR1C1 = "=VLOOKUP(RC[-50],"
& Cusip.Address(external:=True, ReferenceStyle:=xlR1C1) & ",3,FALSE)

Spreadsheet:

=VLOOKUP(E12,CorpA!$A$1:$D$2027,4,FALSE)

Thanks,
Wes

Dave Peterson[_2_]

Vlookup error
 
Cusip is a range variable in your code. If that variable is pointing to
A1:D2027 on the CorpA worksheet, then your code is doing things exactly correctly.

If you think that Cusip should be pointing to a different range on a different
worksheet, then that's the part of the code that you'll need to share.

For instance, if Cusip should be pointing at the same worksheet that contains
the formula, then you'd want something like:

set Cusip = Corp.range("a1:d2027")

But it's difficult to guess...

On 10/01/2011 14:43, wesley holtman wrote:
Hello,

I've got a Vlookup formula that when I execute it, it totally changes
the lookup array. I entered the range "Cusip" as the lookup array in
the VBE but it shows up as "CorpA" in the spreadsheet. What am I doing
wrong?

VBE:

Corp.Range("BC4").Resize(DataRow, 1).FormulaR1C1 = "=VLOOKUP(RC[-50],"
& Cusip.Address(external:=True, ReferenceStyle:=xlR1C1)& ",3,FALSE)

Spreadsheet:

=VLOOKUP(E12,CorpA!$A$1:$D$2027,4,FALSE)

Thanks,
Wes


--
Dave Peterson


All times are GMT +1. The time now is 09:56 AM.

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