Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.FormatConditions.Delete
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 5
End With
End With
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 5
End With
End Sub
更新1:
這段可以實現列、行外框變色,且可使用複制貼上功能。誰能幫我再修改一下:將外框加粗? Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Cells.FormatConditions.Delete With Columns(Target.Column).FormatConditions .Delete .Add xlExpression, , "true" .Item(1).Borders(7).ColorIndex = 5 .Item(1).Borders(10).ColorIndex = 5 End With With Rows(Target.Row).FormatConditions .Delete .Add xlExpression, , "true" .Item(1).Borders(8).ColorIndex = 5 .Item(1).Borders(9).ColorIndex = 5 End With End Sub