Wednesday, August 9, 2023

Cannot run the macro [*]. The macro may not be available in this workbook + custom button in Excel that goes to previous sheet

"Cannot run the macro [filename.xlsm'!macroname']. The macro may not be available in this workbook or all macros may be disabled." 


How to solve this macro problem in Microsoft Excel? I created a shape so it would function as a button that goes back to the previous sheet or the next sheet. But my macro didn't run. That guy just walks off on it's own. Maybe going to the next town, getting some milk. Who knows? 

Sorry I'm so sorry. I was creating my own inventory Excel but encounter this hurdle. So here's how I solved it? 

1. Ctrl+click on that button, (so I could select that button) 

2. right click (I want to get second opinion) 

3. look for 'Assign macro...', click on it. 

4. Next, assign newly made Macro to that button. Basically I just override that error. Good bye error. See you never! 


I forgot step 0. 

0. Record a brand new Macros from View > Macros > Record Macro... 

0a. Give your 'Macro name:', but without spaces. Maybe use underscore if you need to. Give description like 'This macro goes hard'. No no no. Write the description as 'This macro go to previous sheet using Ctrl + Page Up' or something like that. 

0b. Click 'OK', 

0c. If it says 'Macro with name 'blablablah' already exists. Replace existing macro? > YES please! 

0d. Actually when you start pressing that OK, it will start to record. So, after that OK, just go on press Ctrl + Page Up together. 

0e. Click 'Macros' > Stop Recording. That should be it. 

0f. Go back to your button just now, click on it. It should bring you back to previous sheet. That error 'Cannot run the macro...' should be gone by now. 


The last step is to save it into your computer. Save it as a file with extension of .xlsm. 

File > Save As > This PC > Desktop > go to the Save as type > choose Excel Macro-Enabled Workbook (*/xlsm) > click Save. And you're done. 

Close all your Excels and everything. Try open that Excel with macro and try clicking on your button again. It should work. If it didn't, Sorry, I don't know how to solve that. Magically it works when I'm doing it here. 


Tips: 

: For button going to next sheet, record it: Ctrl + Page Down. Yeah, that Ctrl key in your keyboard. Press it together with Page Down keyboard. 

: Let's say you want to remove all macros... Oh no, I actually save a back up before saving it as xlsm file. In case I want a macro free Excel. 

Another option is delete that macro-ed button and create a new one. View your macros and delete all unused macros. 

: In order for macro to work, when opening that xlsm Excel, you need to 'Enable content'. It appears below the ribbon. If you didn't enable it, that Excel becomes read only file. Hahahaha. 


I guess that's it? This method worked with Microsoft Office LTSC Professional Plus 2021. Eh, I thought it was Microsoft 365? I download Excel app from Explore all your Apps in Microsoft 365... 

Last but not least, 

I've uploaded that xlsm file in OneDrive, and try clicking on my macro-ed button, but it didn't work. Button with hyperlink to Index sheet is working. But macro-ed button do nothing... 

Thank you to Youtube: Two Quick Shortcuts to Switch Sheets in Excel #Shorts for the Excel sheet keyboard shortcut. 



Bye.

No comments:

Post a Comment