View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gareth_Evans (InterCall EMEA) Gareth_Evans (InterCall EMEA) is offline
external usenet poster
 
Posts: 18
Default Hightlight cells that contain special characters

I've managed to get the following VBA code from another user and ameded
slightly for my use - this brings up a text box which shows the cell
reference and contents in a pop up message box.

Is there a way I can replace "'find é in text" with a generic statement
which checks for all characters that aren't A-Z, a-z 0-9? The only other
alternative would be to type them all out?

How can I highlight a cell containing one of these un-required characters
with a yellow background (or any colour) instead of it popping up in a
message box?

Best regards,

Gareth

Sub FindCellsWithAsterisks()
'find é in text
Dim cell As Range, FirstAddress As String, FoundList As String
With ActiveSheet.UsedRange
'use tilde to find é
Set cell = .Find("~é", LookIn:=xlValues, SearchOrder:=xlByRows, _
LookAt:=xlPart)
If Not cell Is Nothing Then
FirstAddress = cell.Address '< Bookmark start point
Do
FoundList = FoundList & "Cell " & cell.Address(0, 0) & _
" =" & vbTab & cell & vbNewLine
Set cell = .FindNext(cell)
Loop Until cell Is Nothing Or cell.Address = FirstAddress
End If
End With
'show search results
MsgBox FoundList
Set cell = Nothing
End Sub