Macro to Change All Font Colored with a Macro In a Workbook To Black and Macro to Then Undo

dave1982

New Member
Joined
Mar 1, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
This is a macro I've seen and used before; however, I can't find any code for it. The macro would change the font color of all cells that had been changed to VBRed, VBBlue, or VBGreen using a macro on the Quick Access ToolBar to Black. There was also a macro that would undo this change and change all these cells back to the original VBRed, VBBlue or VBGreen Font Color. Does anyone have the code for these two macros?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Macro to change font color of cells with VBRed, VBBlue, or VBGreen to Black:

Sub ChangeFontColorToBlack()
Dim cell As Range

For Each cell In Selection
If cell.Font.Color = RGB(255, 0, 0) Or _
cell.Font.Color = RGB(0, 0, 255) Or _
cell.Font.Color = RGB(0, 176, 80) Then
cell.Font.Color = RGB(0, 0, 0) 'Change font color to Black
End If
Next cell
End Sub

Macro to revert font color of cells back to VBRed, VBBlue, or VBGreen:

Sub RevertFontColor()
Dim cell As Range

For Each cell In Selection
If cell.Font.Color = RGB(0, 0, 0) Then
If cell.Interior.Color = RGB(255, 0, 0) Or _
cell.Interior.Color = RGB(0, 0, 255) Or _
cell.Interior.Color = RGB(0, 176, 80) Then
cell.Font.Color = cell.Interior.Color 'Revert font color
End If
End If
Next cell
End Sub

You can add these macros to your Quick Access Toolbar by following these steps:

Press Alt + F11 to open the VBA editor.
In the VBA editor, go to Insert > Module to insert a new module.
Copy and paste the respective macro codes into the module window.
Close the VBA editor.
Right-click on the Quick Access Toolbar and select Customize Quick Access Toolbar.
In the Choose commands from dropdown, select Macros.
Add the macros to your Quick Access Toolbar by selecting them from the list and clicking Add.
Click OK to close the dialog box.
Now you can use these macros directly from your Quick Access Toolbar in Excel.
 
Upvote 0
The macro to change all the text to black worked great; however, the RevertFontColor() macro does not seem to work.
 
Upvote 0
Macro to change font color of cells with VBRed, VBBlue, or VBGreen to Black:

Sub ChangeFontColorToBlack()
Dim cell As Range

For Each cell In Selection
If cell.Font.Color = RGB(255, 0, 0) Or _
cell.Font.Color = RGB(0, 0, 255) Or _
cell.Font.Color = RGB(0, 176, 80) Then
cell.Font.Color = RGB(0, 0, 0) 'Change font color to Black
End If
Next cell
End Sub

Macro to revert font color of cells back to VBRed, VBBlue, or VBGreen:

Sub RevertFontColor()
Dim cell As Range

For Each cell In Selection
If cell.Font.Color = RGB(0, 0, 0) Then
If cell.Interior.Color = RGB(255, 0, 0) Or _
cell.Interior.Color = RGB(0, 0, 255) Or _
cell.Interior.Color = RGB(0, 176, 80) Then
cell.Font.Color = cell.Interior.Color 'Revert font color
End If
End If
Next cell
End Sub

You can add these macros to your Quick Access Toolbar by following these steps:

Press Alt + F11 to open the VBA editor.
In the VBA editor, go to Insert > Module to insert a new module.
Copy and paste the respective macro codes into the module window.
Close the VBA editor.
Right-click on the Quick Access Toolbar and select Customize Quick Access Toolbar.
In the Choose commands from dropdown, select Macros.
Add the macros to your Quick Access Toolbar by selecting them from the list and clicking Add.
Click OK to close the dialog box.
Now you can use these macros directly from your Quick Access Toolbar in Excel.
Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top