Macro Save Workbook Name for (Re)Activate

ChuckRobert

Board Regular
Joined
Feb 26, 2009
Messages
64
I am trying to run a macro from workbook A that opens workbook B (containing appointments), copies required data and paste it into workbook A.

The challenge I have is that workbook A is renamed each week as 05/18/2009.xls....05/25/2009.xls. (etc.) so if I hard code the re-activate workbook A (to paste) with the current workbook name will not work next week once re-named.

Could I get a suggestion on code that would enable the Macro to first look for the current workbook name, then use that reference to re-activate the sheet later in the code?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Well don't hardcode and don't 're-activate'.:)

Create a reference to the workbook (A?) the code is in like this:
Code:
Set wbThis = ThisWorkbook
You can now use this in the rest of the code whenever you want to refer to that workbook, for example to activate it.
Code:
wbThis.Activate
But you shouldn't need to activate anyway, but that's hard to tell without seeing some of your code.:)
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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