You can use RegExp for the same effect.
The advantage of the Regex approach, which is code, immediately isolates any group of numeric characters (or skips any lines that don't have a number), rather than checking every single character.
Thus, it offers an advantage in speed if you process large data sets.
Sub RegExpRed() Dim objRegex As Object Dim RegMC As Object Dim RegM As Object Set objRegex = CreateObject("vbscript.regexp") With objRegex .Global = True .Pattern = "\d+" If .test(Cells(1, 1).Value) Then Set RegMC = .Execute(Cells(1, 1).Value) For Each RegM In RegMC Cells(1, 1).Characters(RegM.FirstIndex + 1, RegM.Length).Font.Color = vbRed Next End If End With End Sub
brettdj
source share