default_name
Board Regular
- Joined
- May 16, 2018
- Messages
- 180
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
Hello everyone!
Back in 2018 you guys helped me with some VBA code that would set the color of a certain tab in a timekeeping/pay period workbook depending on the date.
(see Tab Color Dependent on Date)
With a few tweaks over the years, the code used in the solution has worked flawlessly over the years! (thank you!)
However, now, I am attempting to add on to the code, but I am hesitant because I do not want to break it.
In addition to identifying a sheet based on the current date and changing the tab color, I would like for the workbook to open on the identified sheet when the file is opened.
Dates for each day in a pay period are displayed in the following cells of each worksheet: F1:S1
Dates are only listed once in the workbook.
Here is the code that I currently have:
Would it be as simple as adding a line of code that opens the tab containing the result of the Fnd operation?
Thanks in advance!
I appreciate all of your help and support over the years!
Back in 2018 you guys helped me with some VBA code that would set the color of a certain tab in a timekeeping/pay period workbook depending on the date.
(see Tab Color Dependent on Date)
With a few tweaks over the years, the code used in the solution has worked flawlessly over the years! (thank you!)
However, now, I am attempting to add on to the code, but I am hesitant because I do not want to break it.
In addition to identifying a sheet based on the current date and changing the tab color, I would like for the workbook to open on the identified sheet when the file is opened.
Dates for each day in a pay period are displayed in the following cells of each worksheet: F1:S1
Dates are only listed once in the workbook.
Here is the code that I currently have:
VBA Code:
Private Sub Workbook_Open()
Dim Ws As Worksheet
Dim Fnd As Range
For Each Ws In Worksheets
Set Fnd = Ws.Range("F1:S1").Find(Date, , , xlWhole, , , , , False)
Ws.Tab.Color = IIf(Fnd Is Nothing, False, vbBlack)
Next Ws
End Sub
Would it be as simple as adding a line of code that opens the tab containing the result of the Fnd operation?
Thanks in advance!
I appreciate all of your help and support over the years!
Last edited: