2012-02-02 89 views

回答

31

Range("Z1").Interior.ColorIndex = xlNone

+1

完美。非常感谢。你能指点我这个知识的参考吗? MSDN似乎没有立即可以访问:[ColorIndex](http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.interior.colorindex%28v=office.11​​%29 .aspx)没有透露任何有关透明度的信息。 [此页面列出x1None(http://msdn.microsoft.com/en-us/library/microsoft.office.core.xlconstants.aspx),但不带任何说明(?!GRR)有趣的是它也列出xlTransparent其中有一个(不出所料)不起作用的不同价值。无论如何,非常感谢您的帮助! – AJP 2012-02-02 18:33:42

+3

使用'xlNone'与在Excel的菜单中选择“无填充”相同:它不是“真正的”透明。从技术上讲,它可能应该是'xlColorIndexNone',但它们具有相同的值... ColorIndex属性适用于其他对象,如字体和边框,所以这就是为什么您可能会看到应用于Interior.ColorIndex时无效的值有时候最好的办法就是记录一个宏,看看会产生什么。对象浏览器(在VB编辑器中按F2)也很有用。 – 2012-02-02 21:07:12

+0

再次,完美,谢谢蒂姆,希望我能给出更多的观点。录制宏工作出色: '子宏1() 范围。( “T1:W4”)选择 随着Selection.Interior .Pattern = xlNone .TintAndShade = 0 .PatternTintAndShade = 0 结束随着 结束子' – AJP 2012-02-04 17:47:43

-1
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 
+0

有些解释会很好。 – rayryeng 2015-02-19 21:47:30

0

也许一个简单的方法是(Symbol).(line or background)Color = -1 'Transparent