标签:change mamicode lex 技术 tco obj cond rgb 模式
打开excel按照alt+F11(或者打开"开发模式,选择Visual Basic"),选择ThisWorkbook写入如下代码Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireColumn
.FormatConditions.Add xlExpression, , "=true"
.FormatConditions(1).Interior.Color = RGB(253, 255, 200)
End With
With Target.EntireRow
.FormatConditions.Add xlExpression, , "=true"
.FormatConditions(2).Interior.Color = RGB(253, 255, 200)
End With
End Sub
效果如下
选择另外存为xlsm格式即可
标签:change mamicode lex 技术 tco obj cond rgb 模式
原文地址:https://blog.51cto.com/songhl/2530903