Clear highlighted yellow cells back to no fill colour

M4TVD

New Member
Joined
Mar 23, 2021
Messages
25
Office Version
  1. 365
Platform
  1. Windows
I have a macro that fills the row that has been selected (with the colour yellow), this code (in the sheet code) is set up so that I can select 1 row in each selection (selections are separated by rows coloured grey), that allows me to selects one row in each selection to create a group of different parts (like a pick list with one part from each department).

I want to add a separate macro to clear all the yellow highlights and return the data in that yellow filled rows back to no colour fill. I DO NOT want to clear all contents from those rows, only remove the colour fill yellow.

I have tried a few different codes but I am struggling to have only clear fill colour yellow and not contents.

VBA Code:
Sub Clear_ValuesYellow()

    Application.ScreenUpdating = False

    Dim Myrange As Range, cel As Range

    Set Myrange = Range("A1:M106")

    For Each cel In Myrange

        If cel.Interior.ColorIndex = 6 Then

            cel.Interior.colourIndex = 0

        End If

    Next cel

    Application.ScreenUpdating = True

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You have a typo where you are trying to set the colour to 0, remove the u from ColourIndex
 
Upvote 0
Solution
Doh, how obvious..... I forgot that its the American spelling!
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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