working on multiple workbooks

dhx10000

Board Regular
Joined
Jul 11, 2005
Messages
144
Hi,

I have two workbooks in the same folder. I want to have one workbook that will be manually opened by users, but that contains a macro within the workbook_open, that will open another workbook to pull data from. I wrote the code but its not working, I get an error asking me to debug and when I debug it points to this line ('Workbooks("Barcelona-metrics-new.xls").Sheets("WeeklyData").Select').

Just to explain a little, I included this line of code because it appeared excel was getting confused as to which workbook to add my Unique formulas code to. I thought I have to tell excel to open BarcelonaInternalActions.xls (which contains the main data), then tell it to switch to Barcelona-metrics-new.xls, which is where I want to copy formulas and pull data from the first workbook:
---------------------------------------------------------------
Private Sub Workbook_Open()

Workbooks.Open FileName:= _
"http://MyServer/sites/wtbu/umts/barcelona/Action Items/metrics/BarcelonaInternalActions.xls"

Workbooks("Barcelona-metrics-new.xls").Sheets("WeeklyData").Select

'Copy Unique Weeks formula
Range("Q1") = "UniqueWeeks"
Range("Q2") = "=IF(ROW()-ROW($Q$2)+1<=$P$2,INDEX(UNIQUEVALUES([BarcelonaInternalActions.xls]Metrics!$AB$2:$AB$5305,1),ROW()-ROW($Q$2)+1),"""")"
Range("Q2").Select
Selection.Copy
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,214,887
Messages
6,122,095
Members
449,064
Latest member
Danger_SF

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