Forum Discussion
VBA code fail Auto highlight
Did you save the file as Macro-Enabled Workbook?
Point to remember is, only .xls or .xlsb or .xlsm file can hold the macro in it.
Yeah, even when I apply to a new file or save and open as xsl etc it still doesn’t apply. Saves the code fine but doesn’t make a difference.
- Subodh_Tiwari_sktneerMar 12, 2020Silver Contributor
Check the attached in which I have placed the code on Sheet1 Module, let me know if that works for you.
Make sure to enable the macros in the file when prompted. If macros are disabled, they won't work.
- LauraDaisyMar 13, 2020Copper ContributorHi
The code worked fine when I used your spreadsheet, but when I opened a new excel file and added the module it didn’t work.
How do I make it active in the spreadsheet? It’s Saved as macro-enabled before I added the code but it’s not highlighting the rows.
Thanks- Subodh_Tiwari_sktneerMar 13, 2020Silver Contributor
This is selection change event code which gets triggered automatically when you change the selection on the sheet and it should be placed on the Sheet Module but not on a standard module like Module1.
To place the code on to the Sheet Module, right click on the Sheet Tab Name and choose View Code and then paste the code into the opened code window, save your file as Macro-Enabled Workbook.
The file I uploaded with the code would work each time you open it because the code was placed on the Sheet Module.