default_name
Board Regular
- Joined
- May 16, 2018
- Messages
- 180
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
Hello!
I am new here, but I have a question regarding tab colors.
I have a workbook that is split up into pay periods for a record of timekeeping.
Each pay period is represented on an individual tab (there are several tabs in the workbook [the workbook contains pay periods for the entire year]).
I am trying to write a macro that would automatically highlight the worksheet tab (or change the tab color to something like yellow) that corresponds to the current pay period.
Dates for each day in the pay period are displayed in the following cells of each worksheet:
Not sure if my question is making sense...
I am not so sure I am writing the macro correctly.
Here is what I have so far:
Thanks in advance!
I am new here, but I have a question regarding tab colors.
I have a workbook that is split up into pay periods for a record of timekeeping.
Each pay period is represented on an individual tab (there are several tabs in the workbook [the workbook contains pay periods for the entire year]).
I am trying to write a macro that would automatically highlight the worksheet tab (or change the tab color to something like yellow) that corresponds to the current pay period.
Dates for each day in the pay period are displayed in the following cells of each worksheet:
D1:H1
D19:H19
Basically, I want the tab to highlight based on the current date so it is easier to see which tab/pay period I should be on.D19:H19
Not sure if my question is making sense...
ie: If today's date is 5/16/18 (which it is), then the worksheet in the workbook where 5/16/18 is found in one of those cells (D1:H1 or D19:H19) should have a yellow tab.
I am not so sure I am writing the macro correctly.
Here is what I have so far:
Code:
Private Sub Worksheet_Calculate()
If Range("D1:H1","D19:H19").Value = "Today()" Then
Me.Tab.ColorIndex = 6 ' Yellow
Else
Me.Tab.ColorIndex = -4142 ' No Color
End If
End Sub
Thanks in advance!