Hello, I brazenly copied the below macro section to check the range for the value "Not Allowed". And that works, except if none are found it still ends the sub. If none are found, I would like it to process the rest of the macro. Currently, it counts the number of occurrences "Not Allowed" happens and then give a message box. Ultimately, counting the "Not Allowed" is not necessary (it is nice to have, but not necessary), just want to make sure that if any instance of "Not Allowed" shows on the sheet, it does not run the macro and exits for the user to fix. If there are no instances of "Not Allowed" the macro continues to run. Here is where I am stuck. If "Not Allowed" is not found in the range, it just give a message box answer of "0 new item samples...." and ends the sub. Any help would be greatly appreciated. Thanks.
Dim rngData As Range
Dim rngCell As Range
Dim counter As Long: counter = 0
Set rngData = Range("AF38:AF" & Cells(Rows.Count, Range("AF38").Column).End(xlUp).Row)
For Each rngCell In rngData
If rngCell.Value = "Not Allowed" Then
counter = counter + 1
End If
Next rngCell
MsgBox counter & " New items samples are not allowed for this customer. Please remove item(s) and try again", vbCritical
[rest of macro follows here]
Dim rngData As Range
Dim rngCell As Range
Dim counter As Long: counter = 0
Set rngData = Range("AF38:AF" & Cells(Rows.Count, Range("AF38").Column).End(xlUp).Row)
For Each rngCell In rngData
If rngCell.Value = "Not Allowed" Then
counter = counter + 1
End If
Next rngCell
MsgBox counter & " New items samples are not allowed for this customer. Please remove item(s) and try again", vbCritical
[rest of macro follows here]