View Full Version : How to hide cells based on values

03-21-2016, 01:19 AM
Hello everyone,

I've got some panic..

I can write vba scripts but this time I have a very short deadline.

I have like 100 Excelfiles where the cells that has no yellow (XLnone) background need to be hidden.

Could someone help me ?

Thank you in advance

03-21-2016, 02:31 AM
What exactly do you mean, when you sau you want to hide the cells? Do you want to hide the rows, or columns? Do you want to delete the cell contents?

03-21-2016, 02:37 AM
Sorry my bad.

I actually need to update the question.

I need to loop through all used cells that has backgroundcolor xlNone and change the cells to interior.colorindex=2

03-21-2016, 02:47 AM
If by "used" cells you mean they are not empty, then something like:

Sub foo()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If Not IsEmpty(c) And c.Interior.ColorIndex = xlNone Then c.Interior.ColorIndex = 2
Next c
End Sub