Greetings, I created a date picker from scratch using User Form with numerous Macros. Fortunately, it all works great. I only need one more component to it. I would like the current date illuminated.
Of all the macros I think I know the one I want to add it to, or I think I would need a whole new macro like if have for the button that highlights the button currently selected. The two macros I'm basing my theory around are below.
The back color I'm hoping to have the code "btn.BackColor = VBA.RGB(241, 239, 145)
Thank you so much!
Macro which command buttons (dates) are selected.
Sub reset_color()
Dim i As Integer
Dim btn As MSForms.CommandButton
For i = 1 To 42
Set btn = Me.Controls("CommandButton" & i)
If btn.Caption = "" Then
btn.Enabled = False
btn.BackColor = VBA.RGB(115, 197, 219)
Else
btn.Enabled = True
btn.BackColor = VBA.RGB(63, 243, 243)
End If
Next i
End Sub
Alternately a whole new macro created very similar to this one.
Sub highlight_Date(dt As Date)
Dim i As Integer
Dim btn As MSForms.CommandButton
For i = 1 To 42
Set btn = Me.Controls("CommandButton" & i)
If VBA.CStr(VBA.Day(dt)) = btn.Caption Then
btn.BackColor = vbWhite
End If
Next i
End Sub