Question : Excel macro to find all instances

I have a macro to find black filled cells and replace with a light blue color.

I would also like to add find/replace text in those cells changing text color from white to black.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Sub ReplaceByFormat()
Application.FindFormat.Clear
Application.FindFormat.Interior _
.ColorIndex = 1
Application.ReplaceFormat.Clear
Application.ReplaceFormat.Interior _
.ColorIndex = 24
 
Cells.Replace What:="", _
Replacement:="", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=True, _
ReplaceFormat:=True
End Sub

Answer : Excel macro to find all instances

To change the white font to black in the cells that have a black background, you need to add another line under Application.ReplaceFormat.Interior.ColorIndex = 24 that calls out the color change you want for the text:

Application.ReplaceFormat.Font.ColorIndex = 1

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Sub ReplaceByFormat()
Application.FindFormat.Clear
Application.FindFormat.Interior _
.ColorIndex = 1
Application.ReplaceFormat.Clear
Application.ReplaceFormat.Interior _
.ColorIndex = 24
Application.ReplaceFormat.Font.ColorIndex = 1
 
 
Cells.Replace What:="", _
Replacement:="", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=True, _
ReplaceFormat:=True
End Sub
Random Solutions  
 
programming4us programming4us