I have already built my ComboBox list from a column. What I need help with is when I click on a button, it runs code to open a userform. Based on date and time, I want to populate a ComboBox with a value so the user doesn't have to type it in, but can change it based on different circumstances. I get an error on the ' Me.Shift = Shift_Ltr' line. I've tried multiple different things before posting. So based on the outcome of my date and time, I want to load Shift_Ltr into the ComboBox named "Shift" on my userform. From there the user can change it if necessary.
VBA Code:
Sub Show_Sort_Entry_Form()
Dim Entry_Time, Entry_Date As Date
Dim Shift_Ltr As String
Entry_Time = Hour(Now()) & ":" & Minute(Now())
Entry_Date = Month(Now()) & "/" & Day(Now()) & "/" & Year(Now())
If (Entry_Time > "8:00" And Entry_Time < "20:00") Then
Shift_Ltr = ThisWorkbook.Sheets("Data").Range("K:K").Find(Entry_Date).Offset(, 1).Value
Else
Shift_Ltr = ThisWorkbook.Sheets("Data").Range("K:K").Find(Entry_Date).Offset(, 2).Value
End If
Sort_Entry_Form.Show vbModeless
Me.Shift = Shift_Ltr
End Sub