Set all sheets' fill color to "No Fill" using VBA in excel
Asked Answered
C

4

21

How can I Set all sheets fill color to No fill using VBA in excel (all cells). Same as select all sheets, Select all cells (Control+A) and change fill color to No fill.

Caesura answered 5/12, 2016 at 11:33 Comment(0)
P
38

Untested but should do the job:

Sub No_Fill_Wb()

Dim ws as worksheet

For each ws in Thisworkbook.Worksheets
    ws.Cells.Interior.ColorIndex = 0
Next ws

End Sub
Phlebotomy answered 5/12, 2016 at 11:53 Comment(1)
Equivalent would also be ws.Cells.Interior.ColorIndex = xlNoneAtalya
P
24

I used "0" in my code (see below) working with Excel 2016 and it turned my columns black.

Master.Columns(Col_Start).Interior.Color = 0

Using "xlNone" per below, however, did work for me.

Master.Columns(Col_Start).Interior.Color = xlNone 
Plage answered 19/7, 2018 at 17:57 Comment(1)
This is because when you set Range.Interior.Color, it expects a long corresponding to the RGB values. 0 -> #000000 which is black. Range.Interior.ColorIndex increments through the default color palette, for which 0 is No FillKamalakamaria
F
-1

xlNone doesn't work for BackgroundPatternColor but wdColorAutomatic does

currentCell.Shading.BackgroundPatternColor = wdColorAutomatic

Foreshorten answered 16/2, 2022 at 15:46 Comment(1)
There is no Word tag in question, Excel only.Mudd
B
-3

Hey guys you can use this for selecting "No Fill" option "ThisWorkbook.Sheets(1).Interior.Color = xlNone" otherwise if you want to set any background color you can use this way "ThisWorkbook.Sheets(1).Interior.Color = vbgreen"

Bonacci answered 24/1, 2019 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.