我目前拥有:
Range("Z1").Interior.Color = RGB(255, 255, 255)
但是这样会清除单元格的边框。相反,我只想将范围内单元格的透明度设置为1.0。文档似乎表明它不存在(?)。
谢谢!
我目前拥有:
Range("Z1").Interior.Color = RGB(255, 255, 255)
Range("Z1").Interior.ColorIndex = xlNone
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' Clear the color of all the cells
Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row and column that contain the active cell
.EntireRow.Interior.ColorIndex = 8
.EntireColumn.Interior.ColorIndex = 8
End With
Application.ScreenUpdating = True
End Sub
也许一个简单的方法是 (符号).(线条或背景)颜色 = -1 '透明
。
xlNone
和在 Excel 菜单中选择“无填充”是相同的,它并不是真正的“透明”。从技术上讲,可能应该使用xlColorIndexNone
,但它们具有相同的值...... ColorIndex 属性也适用于其他对象,如字体和边框,所以当应用于 Interior.ColorIndex 时,您可能会看到没有效果的值。有时参考最好的方法就是录制一个宏并查看生成的内容。对象浏览器(在 VB 编辑器中按 F2)也很有用。 - Tim WilliamsSub Macro1() Range("T1:W4").Select With Selection.Interior .Pattern = xlNone .TintAndShade = 0 .PatternTintAndShade = 0 End With End Sub
- AJP