Thread: Vlookup error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson[_2_] Dave Peterson[_2_] is offline
external usenet poster
 
Posts: 420
Default 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