Clear highlighted yellow cells back to no fill colour

M4TVD

New Member
Joined
Mar 23, 2021
Messages
19
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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,883
Office Version
  1. 365
Platform
  1. Windows
You have a typo where you are trying to set the colour to 0, remove the u from ColourIndex
 
Solution

M4TVD

New Member
Joined
Mar 23, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Doh, how obvious..... I forgot that its the American spelling!
 

Watch MrExcel Video

Forum statistics

Threads
1,130,172
Messages
5,640,584
Members
417,152
Latest member
DayTimeSeby

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
Top