VBA Code/Excel Formula to Change Cell Value Based on Font Color

euge_prime2001

New Member
Joined
Aug 4, 2017
Messages
8
Hi All,

I would like to seek your assistance if there's a way (excel formula or VBA code) that would assign those cells with value font color black to "0" and those cells with value font color red be the same or no change.

Thanks a lot for your help.

Gene
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hello,

To make this happen when you want the following code needs to go into a standard module:

Code:
Dim MY_CELL As Range
Sub font_colour()
    With ActiveSheet
        For Each MY_CELL In .UsedRange
            If MY_CELL.Font.Color = vbBlack And Not (IsEmpty(MY_CELL)) Then
                MY_CELL.Value = 0
            End If
        Next MY_CELL
    End With
End Sub

Does this work as expected?
 
Upvote 0
Here is another macro that you can consider...
Code:
[table="width: 500"]
[tr]
	[td]Sub MakeBlackFontCellsZero()
  Application.FindFormat.Clear
  Application.FindFormat.Font.Color = vbBlack
  Cells.SpecialCells(xlConstants, xlTextValues Or xlNumbers).Replace "", 0, SearchFormat:=True, ReplaceFormat:=False
  Application.FindFormat.Clear
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

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