The following macro will find all spaces and slashes
in column F, G, and H on every worksheet in the active
workbook, and list them on a new sheet:
Sub FindChars()
'Declare local variables.
Dim x As Long, c As Range, NewSht As Worksheet,
HitCount As Long
On Error Resume Next
'Add a new worksheet to the current workbook at the
end.
Worksheets.Add.Move
After:=Worksheets(Worksheets.Count)
Set NewSht = ActiveSheet
HitCount& = 1
'Check every sheet in turn.
For x = 1 To (Worksheets.Count - 1)
DoEvents
'Activate each sheet in turn.
Sheets(x).Activate
Cells.SpecialCells(xlCellTypeConstants).Select
'If this sheet has any cells with constant values,
select them all.
If Selection.Cells.Count > 0 Then
'Check every cell in the selected range.
For Each c In Selection
'If it is in column F, G, or H...
If c.Column = 6 Or c.Column = 7 Or
c.Column = 8 Then
'And if it contains either character being sought...
If (InStr(c.Value, " ") > 0) Or
(InStr(c.Value, "/") > 0) Then
'List it on the new sheet.
HitCount& = HitCount& + 1
NewSht.Cells(HitCount&,
1).Value = "'" & ActiveSheet.Name
NewSht.Cells(HitCount&,
2).Value = "'" & c.Address
NewSht.Cells(HitCount&,
3).Value = "'" & c.Formula
End If
End If
Next c
End If
Next x
'If no characters were found to match, delete the new
sheet and tell user.
If HitCount& = 1 Then
MsgBox "The specified characters were not
found", vbInformation, "FindChars macro"
Application.DisplayAlerts = False
NewSht.Delete
Application.DisplayAlerts = True
GoTo FC_Cleanup
End If
'Done. Clean up. Add headings for the output rows and
resize all columns on NewSht.
NewSht.Cells(1, 1).Value = "Sheet"
NewSht.Cells(1, 2).Value = "Cell"
NewSht.Cells(1, 3).Value = "Value"
NewSht.Cells.Select
NewSht.Cells.EntireColumn.AutoFit
Calculate
NewSht.Activate
FC_Cleanup:
'Free object variables.
Set NewSht = Nothing
Set c = Nothing
MsgBox "Done!"
End Sub
Please note: this macro uses the SpecialCells property
to select cells with constants. If you need to check
cells with formulas,
change SpecialCells(xlCellTypeConstants)
to SpecialCells(xlCellTypeFormulas)
and InStr(c.Value
to InStr(c.Formula