Hi,
I need help building a very simple excel macro that iterates through all cells of the table, checks if they are not a particular color and if so changes to another color. So if the two colors are called BLANK and FILLED respectively, then the psedocode would look like:

for(all cells i){
if(i->color != BLANK)
i->color = FILLED
}

Recommended Answers

All 3 Replies

so you want to change a cell from a particular color to another color, for example cell is black color so you will change to red color, and if cell color is already red do nothing...this is what you mean or what?

not quite...if BLANK was white and FILLED was black, the logic would be that if a cell is not white, change it to black...

hi neclark2, try this hope it helps...

Sub s()
Dim i As Integer

For i = 1 To 10
 Cells(i, 1).Select
 If Selection.Interior.Pattern <> xlSolid Then
     With Selection.Interior
        .ColorIndex = 1
        .Pattern = xlSolid
    End With
       Else
 End If
Next
 
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.