Use a lookup with a variable for the workbook name

  • Thread starter Thread starter Wilbur
  • Start date Start date
W

Wilbur

I have a workbook and I have to use INDEX(...,MATCH(...)) into another
workbook that I have opened and it does not accept the code:
workbook is "2006 MasterMaterials.xls" with worksheet "RawMaterial"

cString = "2006 MasterMaterials.xls"

FormulaR1C1 = "=INDEX([cString]RawMaterial!$J:$J,
MATCH(C3,[cString]RawMaterial!$C:$C,0))"

Anyone have ideas???? I have tried a number of things.

Thanks
 
This won't work, but it gets you closer:

..FormulaR1C1 = "=INDEX([" & cString & "]RawMaterial!$J:$J," & _
"MATCH(C3,[" & cString & "]RawMaterial!$C:$C,0))"

But you've got another problem. .FormulaR1C1 wants the formula in R1C1
reference style.

Or maybe you want:

..Formula = "=INDEX([" & cString & "]RawMaterial!$J:$J," & _
"MATCH(C3,[" & cString & "]RawMaterial!$C:$C,0))"

I have a workbook and I have to use INDEX(...,MATCH(...)) into another
workbook that I have opened and it does not accept the code:
workbook is "2006 MasterMaterials.xls" with worksheet "RawMaterial"

cString = "2006 MasterMaterials.xls"

FormulaR1C1 = "=INDEX([cString]RawMaterial!$J:$J,
MATCH(C3,[cString]RawMaterial!$C:$C,0))"

Anyone have ideas???? I have tried a number of things.

Thanks
 
Wilbur,

Take the variable cString out of the quotes. Try:

FormulaR1C1 = "=INDEX([" & cString & "]RawMaterial!$J:$J,MATCH(C3,[" &
cString & "]RawMaterial!$C:$C,0))"

HTH

Tim
 
Oh! and it should start with something like:

Range("A4").Formula =

and not 'FormulaR1C1' when you use absolute cell references.

Tim

Tim Barlow said:
Wilbur,

Take the variable cString out of the quotes. Try:

FormulaR1C1 = "=INDEX([" & cString & "]RawMaterial!$J:$J,MATCH(C3,[" &
cString & "]RawMaterial!$C:$C,0))"

HTH

Tim

Wilbur said:
I have a workbook and I have to use INDEX(...,MATCH(...)) into another
workbook that I have opened and it does not accept the code:
workbook is "2006 MasterMaterials.xls" with worksheet "RawMaterial"

cString = "2006 MasterMaterials.xls"

FormulaR1C1 = "=INDEX([cString]RawMaterial!$J:$J,
MATCH(C3,[cString]RawMaterial!$C:$C,0))"

Anyone have ideas???? I have tried a number of things.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top