Hi there
At the moment I have a Worksheet_Change event set up to monitor a range of cells.
The range of cells in question have a Data Validation list setup for a dropdown selection of values which are a number of "Shift Times", for example:
13:30 - 21:30
14:30 - 22:30
19:00 - 03:00
21:00 - 05:00
22:30 - 06:30
At the moment, the Worksheet_Change is set up to perform a macro when the exact text of each of these values is entered.
Is there any way that I can have it perform macros depending on two conditions within one cell. For example, if the cell is changed to start with the first five characters being 19:00 it runs a macro and with the last five characters being 03:00 it runs a different macro.
At the moment, if anybody enters a Shift Time that hasn't been pre-programmed for a macro to run when the EXACT shift time has been entered into the cell, it won't do the required task.
Basically, I want the monitored cells to be Universal in that ANY shift time can be entered two macros are run depending on the start and finish time of the shift.
Would this be utilised with the LEFT(A1,5) and RIGHT (A1,5) commands? Or can these not be used in the Worksheet_Change part.
The code that I use at the moment is as follows:
At the moment I have a Worksheet_Change event set up to monitor a range of cells.
The range of cells in question have a Data Validation list setup for a dropdown selection of values which are a number of "Shift Times", for example:
13:30 - 21:30
14:30 - 22:30
19:00 - 03:00
21:00 - 05:00
22:30 - 06:30
At the moment, the Worksheet_Change is set up to perform a macro when the exact text of each of these values is entered.
Is there any way that I can have it perform macros depending on two conditions within one cell. For example, if the cell is changed to start with the first five characters being 19:00 it runs a macro and with the last five characters being 03:00 it runs a different macro.
At the moment, if anybody enters a Shift Time that hasn't been pre-programmed for a macro to run when the EXACT shift time has been entered into the cell, it won't do the required task.
Basically, I want the monitored cells to be Universal in that ANY shift time can be entered two macros are run depending on the start and finish time of the shift.
Would this be utilised with the LEFT(A1,5) and RIGHT (A1,5) commands? Or can these not be used in the Worksheet_Change part.
The code that I use at the moment is as follows:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C10:C46")) Is Nothing Then
Select Case Target.Value
Case Is = "12:00 - 20:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "13:30 - 21:30":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "14:30 - 22:30":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "16:00 - 02:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "18:00 - 02:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "19:00 - 03:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "19:00 - 05:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "19:00 - 07:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "20:00 - 04:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "20:00 - 06:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "20:30 - 06:30":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "21:00 - 05:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "21:00 - 06:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "21:00 - 07:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "21:30 - 06:30":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "22:00 - 06:00":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "22:30 - 06:30":
CODE FOR THIS SPECIFIC SHIFT TIME
Case Is = "":
CODE FOR A SHIFT TIME BEING DELETED
End Select
End If
End Sub