I would like a message to pop up on my spreadsheet if an entry is either blank or greater than 20. Currently an error message will pop up but it will allow the user to navigate to the next cell without correcting the information. If the user inputs "25", I would like the message to pop up and then the original cell to be selected in order for the user to be forced to put a value between 1 and 20.
My current code:
Dim strCurrentCell As String
Dim strB3 As String
Dim strB4 As String
Dim strMessage As String
strCurrentCell = ActiveCell.Address
strB3 = "$B$3"
strB4 = "$B$4"
'Data entry controls
strMessage = "Check your entry for Customers," _
& " there can only be up to twenty" _
& " customers per class period."
If strCurrentCell = strB3 Then
'Assignment of Values from Work Sheet Variable
sngCustomers = Range("Customers").Value
If sngCustomers > 20 Or sngCustomers < 0 Then
MsgBox strMessage, vbOKOnly, "Error"
Range("Customers").Select
Exit Sub
End If
End If
Bookmarks