Setting Workbook to Active Query

FatalLordes

New Member
Joined
Dec 22, 2017
Messages
11
I'm obviously missing something basic here because I'm not grasping it. I want to set the workbook that I've just opened via email, which can be called anything, as active further on in my VBA script. I figured I would have to set it as a variable right at the start, so I've done
Dim smswb As Workbook: Set smswb = ThisWorkbook
Further on in the script I open another workbook which I want to copy some columns from to the first workbook (smswb), but how on earth do I tell the script to set the smswb as active so that I can then select the cell and then paste? I've tried various things but either nothing ever pastes (which makes me assume it isn't being picked as active) or I get errors with my coding.

I thought setting it as a variable would solve it, but no. I've even tried using ThisWorkBook as apparently it will use the workbook that the script is running from (which is the one I've opened up from email) but that didn't work either?

Basically, I have workbook A, which can be called anything because it depends on what people send it, and I need to open workbook B (which has a set name), copy some cells and paste them back into workbook A at a set cell.

Any ideas to point me in the right direction as I'm obviously missing something basic here :(
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Watch MrExcel Video

Forum statistics

Threads
1,129,278
Messages
5,635,258
Members
416,850
Latest member
Sidddharth

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
Top