Hey guys I'm trying to input a time from a cell into a VBA code and have it round to hours and store it in a variable so that it can be tested against a condition. At the moment I have
tempHour = Format(ActiveSheet.Range("C10").Select, "hh")
If (tempHour = 23) Or (tempHour < 7) Then
CurrentShiftName = "Shift 1"
ElseIf (tempHour >= 7 And tempHour < 15) Then
CurrentShiftName = "Shift 2"
ElseIf (tempHour >= 15 And tempHour < 23) Then
CurrentShiftName = "Shift 3"
tempHour is the integer name I'm using to store the time. I'm not sure if that Format() is correct because when I try and troubleshoot it I see that tempHour never changes from 0. The cell that's I understand to be inputted into the formula is just a cell I've formatted to display the 24 hour time. Any help would be appreciated. For the record CurrentShiftName always outputs Shift 1 since temphour never seems to change from zero.
tempHour = Format(ActiveSheet.Range("C10").Select, "hh")
If (tempHour = 23) Or (tempHour < 7) Then
CurrentShiftName = "Shift 1"
ElseIf (tempHour >= 7 And tempHour < 15) Then
CurrentShiftName = "Shift 2"
ElseIf (tempHour >= 15 And tempHour < 23) Then
CurrentShiftName = "Shift 3"
tempHour is the integer name I'm using to store the time. I'm not sure if that Format() is correct because when I try and troubleshoot it I see that tempHour never changes from 0. The cell that's I understand to be inputted into the formula is just a cell I've formatted to display the 24 hour time. Any help would be appreciated. For the record CurrentShiftName always outputs Shift 1 since temphour never seems to change from zero.