高亮颜色标记单元格
高亮颜色标记单元格、行、列、行列实例_会计园
1.高亮颜色标记单元格
VBA代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
2.高亮颜色标记行
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.EntireRow.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
高亮颜色标记列 3.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
4.高亮颜色编辑行列
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
iColor = Int(50 * Rnd() + 2)
With Target.EntireRow.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = iColor
End With
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = iColor
End With
End Sub
高亮颜色标记单元格、行、列、行列实例
1.高亮颜色标记单元格
VBA代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
2.高亮颜色标记行
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.EntireRow.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
3.高亮颜色标记列
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
End With
End Sub
4.高亮颜色编辑行列
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
iColor = Int(50 * Rnd() + 2)
With Target.EntireRow.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = iColor
End With
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = iColor
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
[格变色].FormatConditions.Delete
Target.Name = "格变色"
With [格变色].FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 35
.Item(1).Font.ColorIndex = 3
End With
End Sub
这是我参考wenz写的,只使选中的单元格变色。
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Row > 3 And Target.Row < 99 And Target.Column < 23 Then
On Error Resume Next
Range("a3:r99").Interior.ColorIndex = 42
行 = Target.Row
列 = Target.Column
Cells(行, 列).Interior.ColorIndex = 45
Else
Range("a3:r99").Interior.ColorIndex = 42
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target.EntireRow.Interior.Color = RGB(255, 0, 0) '以红色为例
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
x = Target.Row
y = Target.Column
Union(Rows(x), Columns(y)).Interior.ColorIndex = 3 End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
x = Target.Cells(1).Row
y = Target.Cells(Target.Count).Row For i = x To y
Rows(i & ":" & i).Interior.ColorIndex = 3 Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal T As Range)
Cells.Interior.ColorIndex = 0
T.EntireRow.Interior.ColorIndex = 6 End Sub
本文档为【高亮颜色标记单元格】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。