Using names workbooks in formulas

Blunder1

Active Member
Joined
Jun 2, 2010
Messages
250
Hi,

I have named two workbooks wb1 and wb2 (the real name of wb2 will change depending on the date). I have also named the sheets ws and wt in wb1 and rd2 and rd3 in wb2. I then need to use formulas in wb1 that use use values in wb2, however, i'm struggling to use the workbook names in the formulas.

Below is one of my formulas, i need 'Excelsius Raw Data COB 0905.xls' to be wb2 and the sheet name 'cash' to be rd2.

Code:
ws.Range("c" & r).FormulaArray = "=SUM(('[Excelsius Raw Data COB 0905.xls]Cash'!" & strrng & "=$b$1)*('[Excelsius Raw Data COB 0905.xls]Cash'! " & strrng1 & "=7))"

Thanks in advance

Blunder
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try

Code:
ws.Range("c" & r).FormulaArray = "=SUM(('[" & wb2 & "]" & rd2 & "'!" & strrng & "=$b$1)*('[" & wb2 & "]" & rd2 & "'! " & strrng1 & "=7))"
 
Upvote 0
Do you mean that you have assigned the workbooks and worksheets to object variables? If so try:

Code:
    ws.Range("c" & r).FormulaArray = "=SUM(('[" & wb2.Name & "]" & rd2.Name & "'!" & strrng & "=$b$1)*('[" & wb2.Name & "]" & rd2.Name & "'! " & strrng1 & "=7))"
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top