Is there a code that will change the color of a tab if there is data on the worksheet?
Is there a code that will change the color of a tab if there is data on the worksheet?
The following code placed in the code module for a worksheet will change the tab color to red once data has been entered on the worksheet. It does not change it back again if the sheet subsequently has all data deleted.
If you want code in one place that does it for all worksheets, it's quite a bit trickier but I think it's possible.![]()
Please Login or Register to view this content.
There are a total of 12 tabs in the workbook. I need 8 of them (soon to be 7) to change color if there is data on them.
My best suggestion is to replicate the above code in each of the 8 (soon to be 7) sheets that you want to have the tab change color when data is added. You do not have to change the code except if you want the tabs to be different colors.
I experimented with using a Class to handle events from any sheet but have not gotten it to work yet. Because you only want some of the sheets to have that behavior, that would be a problematic solution anyway.
Another option:
This will remove the Tab Color as well and operates on all Sheets within the workbook. If there are sheets you don't want included you need to place a line at the beginning. In the sample code above it excludes Sheet3![]()
Please Login or Register to view this content.
Last edited by JOHN H. DAVIS; 09-06-2013 at 03:53 PM.
The tab names I need excluded would be the below.
Client List
Combined
Correct File
Research
Hi,
This is a workbook event and has to be placed under "ThisWorkbook" module
I have modified the code provided by John to exclude the specified sheets.
Thanks
![]()
Please Login or Register to view this content.
I am getting an error on this line if the sheet is not completely blank. Using UsedRange in a comparison is failing.
I was able to get this modification to work.![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
It works well for me.
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
maybe its time for me to close the application completely and delete temp files to clean Excel garbage![]()
There are multiple solutions posted close together with multiple members offering commentary but we can't tell who is responding to what.
Let's wait for jscalem to review what's here and post back to tell us whether any of this is solving his problem.![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks