VBA: Is it possible that 3 macros workbooks into one workbook macro?

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello

I have 3 macros workbooks ( 3 macro files).

The question is, is it possible to add 3 macros (workbooks) files into one macro workbook? Ideally I would like each tab to have its own macro to run reports.

I have 3 different types of data files downloaded from a platform in CSV format. I import data into a macro, then into a report, and add extra columns.

Or do you have a better idea on how to do it?

Thank you

Best regards

V
 
Wherever you want the code to run against that sheet.
I have not tried to analyze your code (it would be very difficult to do without all the data) to know where you want things to run.

However, note that in your code, you have sheet references like this:
Rich (BB code):
ActiveWorkbook.Sheets(1).Cells.Copy targetRange
That is referencing the first sheet in the active workbook, regardless of name.

If you wanted it to reference the "Regular" sheet, then you would need to change that, to something like:
Rich (BB code):
ActiveWorkbook.Sheets("Regular").Cells.Copy targetRange


I got it now and I think it works for Regular tab when I clicked its Quick Access button to run but it run for each tab.

See the attached for example.

For the Thankyou tab and Upgrade tab - those will have different codes and should have different Quick Access button for each.

How do I fix that?

Regards
 

Attachments

  • Quick Access Toolbar.PNG
    Quick Access Toolbar.PNG
    60.1 KB · Views: 3
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
If you want to use the same code for all three tabs, instead of entering in the sheet name, you can either remove all Sheet name references, or use "ActiveSheet", and then it will just run against whatever the active sheet is. So you don't need 3 different copies of the same code then.
 
Upvote 0
If you want to use the same code for all three tabs, instead of entering in the sheet name, you can either remove all Sheet name references, or use "ActiveSheet", and then it will just run against whatever the active sheet is. So you don't need 3 different copies of the same code then.
I got it now so it works how I wanted in that way. So thank you for your help on this matter which is much appreciated it!
best regards
Rej
 
Upvote 0
You are welcome.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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