FatalLordes
New Member
- Joined
- Dec 22, 2017
- Messages
- 26
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
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