How to clear all cells with fontcolor 3

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Hi guys,

I have made a script that change color on fonts and cell foreground,

now is my problem

I need to clear all cells with fontcolor 3=red from contents
so they are empty

I dont get it work

Could someone help me?

See code below


Code:
Sub sheofs()




For Each sht In ActiveWorkbook.Worksheets
Set rng = sht.UsedRange
Set MyRange = rng


'Rows(1).Interior.Color = vbBlue
'Rows(1).Font.Color = vbRed






For Each MyCol In MyRange.Columns
For Each myCell In MyCol.Cells




If myCell.Interior.ColorIndex = 23 Then
myCell.Font.ColorIndex = 3
Cells(myCell.Row, 2).Copy
myCell.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False





End If


' I tried this 


'If myCell.Font.ColorIndex = 1 Then
'myCell.Clearcontents
'End If



'
'I have also tried this
'
'If Mycell.Interior.ColorIndex = xlNone Then
'Mycell.ClearContents
'
'End If
'
'










Next


Next
Next




End Sub
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,216,228
Messages
6,129,611
Members
449,520
Latest member
TBFrieds

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