Highlight everything except English letters A-Z

Agarwal2ss

New Member
Joined
Apr 15, 2018
Messages
1
Hello ,
I want either Excel Formula or VBA code so that it can highlight everything in a column (Numbers, special characters, spaces, all foreign alphabets except English letters.) with some color(Red) and cell should be highlighted with Yellow color.

Eg. Cell A1 contains word like "World@1234" than it should highlight special characters(including numbers)
and cell should be highlighted with Yellow color.

Result= World@1234(with yellow cell)

Regards
SA

 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
For text (not formulas) in Column A, give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub ColorNonLettersOnly()
  Dim X As Long, Cell As Range
  Application.ScreenUpdating = False
  For Each Cell In Range("A1", Cells(Rows.Count, "A").End(xlUp))
    If Len(Cell.Value) Then
      For X = 1 To Len(Cell.Value)
        If Mid(Cell.Value, X, 1) Like "[!A-Za-z]" Then Cell.Characters(X, 1).Font.Color = vbRed
      Next
      Cell.Interior.Color = vbYellow
    End If
  Next
  Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
This can be applied to non-contiguous cells if needed. First select all the cells you want altered, then run the macro.
Code:
Sub HighlightExceptAtoZ()
'Select the cells you want to apply this to first, then run this macro
Dim R As Range, cel As Range, ct As Long
If TypeName(Selection) = "Range" Then
    Set R = Selection
Else
    MsgBox "Select a range of cells then try again"
    Exit Sub
End If
On Error Resume Next
Set R = R.SpecialCells(xlCellTypeConstants)
On Error GoTo 0
If R Is Nothing Then
    MsgBox "Can't apply this macro to formulaic cells"
    Exit Sub
End If
Application.ScreenUpdating = False
For Each cel In R
    For i = 1 To Len(cel.Value)
        If Mid(cel.Value, i, 1) Like "[!A-Za-z]" Then
            ct = ct + 1
            cel.Characters(i, 1).Font.Color = vbRed
        End If
    Next i
    If ct > 0 Then cel.Interior.Color = vbYellow
    ct = 0
Next cel
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top