vba to delete remove fill from cel based on colour

CRAIG20

Board Regular
Joined
Mar 20, 2006
Messages
228
Hi.

I would like vba to remove the fill from cells which have been filled yellow. (to revert them to 'no fill')

Thanks in advance

Regards

Craig
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I assume that the fill has been added manually, and is not the result of Conditional Formatting, yes?
Is it confined to a certain range? If so, what range?
You do not have any highlighting beyond the end of your data, do you?
 
Upvote 0
I assume that the fill has been added manually, and is not the result of Conditional Formatting, yes?
Is it confined to a certain range? If so, what range?
You do not have any highlighting beyond the end of your data, do you?

Hi the original fills were added manually.

It wil apply to N5 - N10000

Craig
 
Upvote 0
Does the range contain any other color fill in that range that you want to keep? If not, you can easily remove all fill from that range in one step like this:
Code:
    Range("N5:N1000").Interior.Pattern = xlNone
Otherwise, you will need to loop through to check the color or each cell, i.e.
Code:
Sub MyDeleteYellowFill()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    
    For Each cell In Range("N5:N1000")
        If cell.Interior.Color = 65535 Then cell.Interior.Pattern = xlNone
    Next cell

    Application.ScreenUpdating = True

End Sub
 
Upvote 0
Does the range contain any other color fill in that range that you want to keep? If not, you can easily remove all fill from that range in one step like this:
Code:
    Range("N5:N1000").Interior.Pattern = xlNone
Otherwise, you will need to loop through to check the color or each cell, i.e.
Code:
Sub MyDeleteYellowFill()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    
    For Each cell In Range("N5:N1000")
        If cell.Interior.Color = 65535 Then cell.Interior.Pattern = xlNone
    Next cell

    Application.ScreenUpdating = True

End Sub

Perfect! Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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