Multiple Excel Macros For Different Functions

Brass Contributor

Morning all,

 

Hoping someone can guide me.  I have several different functions that i track for the team reporting to me.  All are tracked in some form of excel workbook, which i copy for each new month, from the prior  month.

 

There are three different functions i track separately - attendance, productivity, quality.  Each of these have vastly different templates and reporting requirements.  While i've developed macros over the past year to simplify the admin side of distributing the details person by person, i have an issue i'm not sure how to resolve.

 

Given each book has it's own requirements for distribution, i don't want all the macros in a single "personal Macro workbook".  Is it possible to have a few "personal macro workbooks", each dedicated to the separate function to allow me access to only the specific macros for that function?  Or is there some other saving/storage/organizational mechanism you would suggest?

 

Thanks

joe

7 Replies

@JoeCavasin 

It'd be easier to store the macros in the workbooks themselves.

When you copy one of the existing workbooks for a new month, you'll copy the macros with it, so the same macros will be available in the new copy.

@Hans Vogelaar 

 

Ok, thanks Hans!  That's what I *thought* i did my first, time around with these macros, but since i'm a relative newb to this stuff, i likely screwed it up.  I'll have to dig around a bit and see why some of the books have the macros and others don't.

@Hans Vogelaar 

 

Hans - can you tell me what i'm missing? I've had this on the back burner for other priorities but looked at one example this morning. If in the VBA editor window opened only on a single excel workbook where i made (and thought i saved) three macros specific to that workbooks function, i see all the macros in a module folder under that workbooks title...

JoeCavasin_0-1646220526228.png

 

And yet when i go to add buttons/icons for these to the ribbon or tool bar, i see them ONLY when i select "Add To All Documents" - shot one below, and they disappear when I select "For Downtime Rollup" only.  My goal is to make them only available in Downtime Rollup.  Did i save them wrong somehow?

 

JoeCavasin_1-1646220861952.png

Thanks

Joe

@JoeCavasin 

That is strange. could you attach a copy of the workbook, or make it available through OneDrive, Google Drive, Dropbox or similar?

@Hans Vogelaar 

 

Yay!  glad it also looks weird to someone else - who knows more of this stuff.  It's been confusing the hell out of me.  I've attached, and hope it's helpful.  I'm sure the macros will be problematic if you need to test since they are all programmed to refer to specific share drive locations the sheet won't be able to access from this forum location...

 

I figure worst case, perhaps i can export the macros, save, and then reimport "to this workbook" only, and save a new version?

 

Thanks!

Joe

@JoeCavasin 

The cause of the problem is that the macros have the same name as the modules they're in.

I changed the names of the modules:

S1189.png

The macros then remain visible:

S1190.png

Remarks:

  1. You renamed the workbook module ThisWorkbook to Copy_Out. That is not a good idea; ThisWorkbook has a special meaning, so renaming it is confusing.
  2. You stored a standard macro Copy_Out in the workbook module. Although this is allowed, it is not a good idea either: the workbook module is intended for workbook-level event procedures such as Workbook_Open. Standard macros belong in standard modules - the kind you create by selecting Insert > Module.
can't thank you enough, i clearly skipped some of the detail in my tutorials on how to insert and name them. Truly appreciate your help, Hans!