Clear Red Cells with VBA

Gerry P

New Member
Joined
Jul 2, 2016
Messages
11
I am totally new to this.....But I need help with a macro that will clear cells that are high lighted Red

I am trying to make a line plot with the combined good values from columns x,y,z x5:z21000

Excel 2013 Red color is rgb 255 Sheet name is " Curve Data "


I could email file if needed................. Thanks in advance for any help
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Are the cells highlighted by filling them red manually or are they filled using conditional formatting?
 
Upvote 0
Try this:

Code:
Sub Clear_Red_Cells()
Dim c As Range

    For Each c In Sheets("Curve Data").UsedRange
        If c.Interior.Color = RGB(255, 0, 0) Then c.Value = Isnothing
    Next

End Sub
 
Upvote 0
You did not answer the question. How did they become Red?

Was it do to conditional formatting.

And do you want the text and the coloring removed or just the text.
And when you say: highlighted you mean the cells interior color correct? Or do you mean font color is red.
 
Upvote 0
I have the cells conditional formatted that if the formula result is #N/A the whole Cell will become red

i tried to post an image and made a mess below oooops.
 
Upvote 0
You did not answer the question. How did they become Red?

Was it do to conditional formatting.

See post #4

@Gerry P try....

Code:
Sub Clear_Red_Cells()
Dim c As Range

    For Each c In Sheets("Curve Data").Range("X5:Z21000")

        If c.DisplayFormat.Interior.Color = RGB(255, 0, 0) Then c.Value = ""
    Next

End Sub
 
Last edited:
Upvote 0
Seeing as you are trying to clear formulas with a #N/A result then as long as you have no other errors you would be better off using the code below.

Code:
Sub Clear_Red_Cells2()
Sheets("Curve Data").Range("X5:Z21000").SpecialCells(-4123, 16) = ""
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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