Jun 17 2018 10:58 AM
I run a small business with a big honkin' spreadsheet with a dozen or so worksheets inside. To facilitate the operations with this spreadsheet, I've created a couple dozen macros to navigate within the spreadsheet, to create reports, to create statements for clients, and so forth.
Every year, when it's time to do the data processing, I copy the previous year's spreadsheet & rename it for the current year. The good news: when I copy "2017" to "2018", the macros get copied with it. If I go to Developer --> Macros, I find the macros associated with the "2018" file. Also, in some spots, I have placed buttons inside a worksheet, and when pressed, those buttons refer to the "2018" macros.
The bad news: I've created a customized ribbon to hold all the macros. The problem is that when I copy "2017" to "2018", the customized ribbon in "2018" refers to the macros in "2017". Thus, when I click on a button on the customized ribbon, Excel opens "2017" and executes the macro in the "2017" file. This is a big problem:
So, my question is: Can I implement a customized ribbon & tell it to refer to the local macros? Therefore, when I copy the spreadsheet at the beginning of the year, the ribbon will automatically refer to the local macros?
Thanks.
Jun 18 2018 12:44 AM
Jun 18 2018 10:32 AM
I'll check the link in more detail, but at first glance, I don't understand it.
The "collection of buttons" solution isn't appealing to me. As I've mentioned, there are a dozen worksheets in the file, and I need the macros available on all worksheets. Plus, there isn't a lot of screen space available for the roughly two dozen macros that are in the ribbons. Finding space for a set of buttons would mean a significant reorganization of all the worksheets & a re-implementation of parts of the macros.
I wonder if I can create a macro to update the custom ribbon after I copy the file?
Jun 19 2018 01:45 AM
SolutionJun 19 2018 11:02 AM - edited Jun 19 2018 11:03 AM
I wouldn't call this solution "elegant", but it works. Thank you.
Note: I found an "onAction" entry for each of the buttons on my customized ribbon, and when I copied the exported customization file, I struggled at first, but then figured out that I could do a "replace all" of the "2017" file name with the "2018" file name. In all, I replaced about 20 occurrences. Then, I opened the "2018" file, imported the edited "2018" customization file, and everything worked. Bonus: I can keep the customizations for each of the different versions of the spreadsheet, making it easy to recreate reports from previous years.
Ideally, Microsoft will consider an option to take care of this -- perhaps an option or checkbox available when creating a button on a customized ribbon that references a macro?
Jun 19 2018 12:01 PM
Jun 19 2018 12:47 PM
That would work for me. To me, it's inconsistent to associate macros to a file and not the customization.
I think it should be an option -- sometimes, I might want some customization to be available for all spreadsheets, but in the case of my small business spreadsheet, I'd want the customization to be associated with the file (so that it gets copied when the file gets copied).
Jun 20 2018 12:47 AM
Jun 19 2018 01:45 AM
Solution