Vlookup error

  • Thread starter Thread starter wesley holtman
  • Start date Start date
W

wesley holtman

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
 
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...

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
 
Back
Top