I want to verify that data in cells of a particular column does not have typos (and/or are in a pre-approved list).
When I tried expanding the range of values to check for 26 or more I get an error. I learned that VBA imposes a limit of 25 lines on certain elements of macros. https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/line-too-long
A sample of my code shortened to show what I am trying to achieve. In the real use case, the code is far longer.
Cities that are valid are flagged in green. Anything else is flagged in red.
Sub checkCities()
Dim myRange As Range
Dim myCell As Range
Set myRange = Range("A2:A1000")
For Each myCell In myRange
If myCell Like "New York" Or _
myCell Like "Chicago" Or _
myCell Like "Boston" Then
myCell.Interior.Color = RGB(0, 128, 0)
Else: myCell.Interior.Color = RGB(128, 128, 0)
End If
Next myCell
End Sub
Are there any workarounds?