remove data but keep the Conditional Formatting

TimHollis

New Member
Joined
Jun 10, 2003
Messages
8
I have colour coded a chart according to values in cells.
So if a cell had "1" in it, it is green, and if it has "2" it is red.

Simple stuff.

I now want to delete the 1's and 2's out of the cells, but keep the colour coding.

That can't be as difficult as i am findin it ... can it?
:oops:

tim
 
This should do the trick. Change the sheet name to whatever the sheet is actually named.

Code:
Sub Test()

Dim Cell As Object

    Sheets("Sheet1").Range("A2:T49").FormatConditions.Delete
    For Each Cell In Sheets("Sheet1").Range("A2:T49")
        Select Case Cell.Value
            Case 1 'Color Green
                Cell.Interior.ColorIndex = 10
            Case 2 'Color Red
                Cell.Interior.ColorIndex = 3
            Case Else
        End Select
    Next
    
End Sub
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Ok - I'll try that - before I do, do you know if this will change one I change the cell values?

i.e. does this update when a cell's value is changed?
 
Upvote 0
If you want it to run whenever a value is changed put the code in the worksheet_change section. Right click on the sheet and select view code. then from the dropdowns select worksheet, then from the second one select change.
 
Upvote 0
An easy solution is to change the font colors to the same color as the shading. Thus the number is actually there but you don't see it because its the same color as the box. Has worked before for me.
 
Upvote 0
I found a quick way to hide the text: use a custom number format of ""

The values remain but they are no longer visible. Easier than trying to mess with individual font colors.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,546
Members
449,169
Latest member
mm424

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