Hello Everyone not quite familiar with Select Case or case but know that is problem what I need done to reduce the VBA code below.
Basaclly what I like to do is use Select Case to go from Cell "AT" thru "AZ" with each case you will notice it checks Cells(y,"E") thru Cells(y,"W") skipping every 2 columns if true changes the Value from Cells(y,"F") thru Cells(y,"X") skipping every 2 columns. I have one for AM for each day of the week and one for PM for each day of the week below however like to reduce the Code. any Help is greatly appreciated.
Basaclly what I like to do is use Select Case to go from Cell "AT" thru "AZ" with each case you will notice it checks Cells(y,"E") thru Cells(y,"W") skipping every 2 columns if true changes the Value from Cells(y,"F") thru Cells(y,"X") skipping every 2 columns. I have one for AM for each day of the week and one for PM for each day of the week below however like to reduce the Code. any Help is greatly appreciated.
VBA Code:
Sub convertRole()
Dim lr As Long
lr = Range("y1")
t = 2
'AM
'SUNDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AT") = True And Cells(y, "E") = Cells(1, x) Then
Cells(y, "F") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'MONDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AU") = True And Cells(y, "H") = Cells(1, x) Then
Cells(y, "I") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'TUESDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AV") = True And Cells(y, "K") = Cells(1, x) Then
Cells(y, "l") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'WEDNESDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AW") = True And Cells(y, "N") = Cells(1, x) Then
Cells(y, "O") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'THURSDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AX") = True And Cells(y, "Q") = Cells(1, x) Then
Cells(y, "R") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'FRIDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AY") = True And Cells(y, "T") = Cells(1, x) Then
Cells(y, "u") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'SATURDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AZ") = True And Cells(y, "W") = Cells(1, x) Then
Cells(y, "X") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'PM
'SUNDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AT") = False And Cells(y, "E") = Cells(1, x) Then
Cells(y, "F") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'MONDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AU") = False And Cells(y, "H") = Cells(1, x) Then
Cells(y, "I") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'TUESDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AV") = False And Cells(y, "K") = Cells(1, x) Then
Cells(y, "l") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'WEDNESDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AW") = False And Cells(y, "N") = Cells(1, x) Then
Cells(y, "O") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'THURSDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AX") = False And Cells(y, "Q") = Cells(1, x) Then
Cells(y, "R") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'FRIDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AY") = False And Cells(y, "T") = Cells(1, x) Then
Cells(y, "u") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
'SATURDAY
For x = 32 To 45
For y = 3 To lr
If Cells(y, "AZ") = False And Cells(y, "W") = Cells(1, x) Then
Cells(y, "X") = Cells(t, x)
t = t + 1
End If
Next y
t = 2
Next x
End Sub