Change color on tab

KlausW

Active Member
Joined
Sep 9, 2020
Messages
401
Office Version
  1. 2016
Platform
  1. Windows
Hi I have a vague plan divided into months, I have tried with this VBA to get the color of the tab as the date you are in now to change the Danish name of the month is in cell E1, but it may not need to happen. The VBA code is in this production's directory, but it's not what's wrong, anyone can help?

VBA Code:
Private Sub Workbook_Open ()


Dim WS As Worksheet

Dim MountNu As String

MountNu = Range ("E1") & WorksheetFumktion.MountNow ()

For Each WS In ThisWorkbook.Worksheets

If WS.Name = MountNu Then

WS.Tab.ColorIndex = 4

Else

WS.Tab.ColorIndex = xlColorIndexNone

End If

Next


End Sub
All help will be appreciated

Regards Klaus W
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
In that case check the sheet names for leading/trailing spaces.
 
Upvote 0
Hi folks !​
Don't you see the typo in the 'WorksheetFunction' codeline ?!​
 
Upvote 0
Did you put the code into the ThisWorkbook module, or into a different module?
 
Upvote 0
These are checks there are no spaces in front of or behind sheet names
Hi Again 1000 thanks for the help, now I have found the problem, the month name was in capital first letter. So it's fixed. Once again thank you. Best regards Klaus W
 
Upvote 0
Glad it's sorted & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,326
Messages
6,130,057
Members
449,555
Latest member
maXam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top