Hi all, I'm looking for help in trying to achieve the following. If any of the values in a range is >1, then use the corresponding name from column A.
The comments in the code below will hopefully explain what I'm hoping for.
I've also created a table for reference.
Thanks in advance
<tbody>
</tbody>
The comments in the code below will hopefully explain what I'm hoping for.
I've also created a table for reference.
Thanks in advance
Code:
Sub ErrorMsg1()
Dim OfficersName As String
Dim Totals As Integer
'if any value in the range b27:h27 is >1, use the officer's name in a27 in the corresponding msgbox
'if any value in the range b31:h31 is >1, use the officer's name in a31 in the corresponding msgbox
'if any value in the range b35:h35 is >1, use the officer's name in a35 in the corresponding msgbox
'if any value in the range b39:h39 is >1, use the officer's name in a39 in the corresponding msgbox
'if any value in the range b43:h43 is >1, use the officer's name in a43 in the corresponding msgbox
Totals = Range("B27").Value
OfficersName = Range("A27")
If Totals > 1 Then
MsgBox OfficersName & " Has been scheduled on 2 or more sites." & vbNewLine & "Please Rectify." & vbNewLine & _
"Press OK to acknowledge.", vbExclamation + vbOKOnly, "Error"
Else
Exit Sub
End If
End Sub
A | B | C | D | E | F | G | H | |
Mon | Tue | Wed | Thu | Fri | Sat | Sun | ||
24 | ||||||||
25 | ||||||||
26 | ||||||||
27 | Officer 1 | |||||||
28 | ||||||||
29 | ||||||||
30 | ||||||||
31 | Officer 2 | |||||||
32 | ||||||||
33 | ||||||||
34 | ||||||||
35 | Officer 3 | |||||||
36 | ||||||||
37 | ||||||||
38 | ||||||||
39 | Officer 4 | |||||||
40 | ||||||||
41 | ||||||||
42 | ||||||||
43 | Officer 5 |
<tbody>
</tbody>