I have a macro that someone on this forum helped me with a while back. The macro works perfectly but now I need to make a modification and the code is way above my skill level. In the current form this macro searches my entire worksheet, finds and selects all cells that are formatted with the text color RGB(1, 2, 2). I need to modify this macro so it only finds and selects cells within my current range of cells that I have selected. So, basically, I no longer want to search the entire sheet, I only want to search within my current selected range. Can someone please help with this? Thanks in advance.
Code:
Sub a_0_0_Change_Colors_to_Automatci()'
' a_0_0_Change_Colors_to_Automatci Macro
'
'
Dim rngFound As Range
Dim rngAll As Range
Dim strFirst As String
Dim lColor As Long
lColor = RGB(1, 2, 2)
With Application.FindFormat
.Clear
.Font.Color = lColor 'Search for font color
'.Interior.Color = lColor 'Search for background color
End With
With ActiveSheet.UsedRange
Set rngFound = .Find("", .Cells(.Cells.Count), SearchFormat:=True)
If Not rngFound Is Nothing Then
Set rngAll = rngFound
strFirst = rngFound.Address
Do
Set rngAll = Union(rngAll, rngFound)
Set rngFound = .Find("", rngFound, SearchFormat:=True)
Loop While rngFound.Address <> strFirst
rngAll.Select
Set rngAll = Nothing
Set rngFound = Nothing
strFirst = vbNullString
Else
MsgBox "No cells found with font color " & lColor & ".", , "No Matches"
'MsgBox "No cells found with background color " & lColor & ".", , "No Matches"
End If
End With
Application.FindFormat.Clear
End Sub