Assign workbook name from a cell to a variable.

vanwooten

New Member
Joined
Dec 15, 2020
Messages
43
Office Version
  1. 365
Platform
  1. Windows
I am trying to automate the transfer of data from one workbook (OrigWB) to another (DestWB) with the same structure but different code. I will instruct them to open both workbooks and select the OrigWB from a list in the new workbook (DestWB) :


2022-08-23.png


So now I need to set the variables. I have tried, among other things:

Set DestWB = ThisWorkbook 'where the procedure resides
strName = DestWB.Worksheets("Resources").Range("C91") 'the cell with the name selected.
Set OrigWB = Workbooks("&strName&") 'get Subscript out of range error here.

Just need to set these. Probably something simple for you guys.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Thank You Alex. I'll Try to give you a bigger challenge next time.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

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