简体   繁体   English

使用 excel 中的 VBA 将所有工作表的填充颜色设置为“无填充”

[英]Set all sheets' fill color to "No Fill" using VBA in excel

How can I Set all sheets fill color to No fill using VBA in excel (all cells).如何使用 excel(所有单元格)中的 VBA 将所有工作表的填充颜色设置为No fill Same as select all sheets, Select all cells (Control+A) and change fill color to No fill .与 select 所有工作表、Select 所有单元格 (Control+A) 相同,并将fill color更改为No fill

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

I used "0" in my code (see below) working with Excel 2016 and it turned my columns black. 我在使用Excel 2016的代码(见下文)中使用了“0”,它将我的列变为黑色。

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

Using "xlNone" per below, however, did work for me. 然而,每个下面使用“xlNone”对我有用。

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

xlNone doesn't work for BackgroundPatternColor but wdColorAutomatic does xlNone 不适用于 BackgroundPatternColor 但 wdColorAutomatic 可以

currentCell.Shading.BackgroundPatternColor = wdColorAutomatic currentCell.Shading.BackgroundPatternColor = wdColorAutomatic

嘿伙计们你可以用它来选择“No Fill”选项“ThisWorkbook.Sheets(1).Interior.Color = xlNone”否则如果要设置任何背景颜色你可以用这种方式“ThisWorkbook.Sheets(1).Interior .Color = vbgreen“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM