tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I got this code yesterday that works great,
it checks if a cell is empty or if it has 6 numbers but i need to change the second criteria?
I need it to check that every cell is a number between 1-999
but hears the problem they can have 1 letter at the end so 1A to 999Z is fine but so is just 1 to 999.
if anyone can help this would be great
Thanks
Tony
heres the code i have
I got this code yesterday that works great,
it checks if a cell is empty or if it has 6 numbers but i need to change the second criteria?
I need it to check that every cell is a number between 1-999
but hears the problem they can have 1 letter at the end so 1A to 999Z is fine but so is just 1 to 999.
if anyone can help this would be great
Thanks
Tony
heres the code i have
VBA Code:
Sub Col_E_CheckForSixDIgitNumbers()
Dim Cell As Range, Yellow As Long, Red As Long, Msg As String
For Each Cell In Data1.Range("E15:E" & Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row)
If Cell.Value = "" Then
Cell.Interior.Color = RGB(255, 255, 0) 'yellow
Cell.Font.Color = RGB(117, 71, 78)
Yellow = 1
ElseIf Cell.Value Like "######" Then 'this is the bit that needs changing?
Cell.Interior.Color = RGB(235, 245, 230) 'light green
Cell.Font.Color = RGB(117, 71, 78)
Else
Cell.Interior.Color = RGB(255, 0, 0) 'red
Cell.Font.Color = RGB(255, 255, 255) 'white
Red = 1
End If
Next
If Yellow + Red = 2 Then
MsgBox "You have some incorrect inputs and blank cells in the ""receipt"" column please fix each red and each yellow cell before proceeding!", , "Column E Has Errors!"
ElseIf Yellow Then
MsgBox """receipt"" column has missing data, please fix each yellow cell before proceeding!", , "Column E Has Errors!"
ElseIf Red Then
MsgBox "You have some incorrect inputs in the ""receipt"" column please fix each red cell before proceeding!", , "Column E Has Errors!"
End If
End Sub