|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_Change(ByVal Target As Range)
Set rng = Target(1)
Thisvalue = rng.Value
r = rng.Row: c = rng.Column
Dim 待着色 As Range, 不着色 As Range
If r > 19 And c > 1 And c < 18 Then
x = rng.Value
r1 = Cells(19, c).End(3).Row
If r1 = 1 Then Exit Sub
c1 = Cells(r1, 256).End(1).Column
If c1 = c Then Exit Sub
Application.EnableEvents = False
arr = Cells(r1, 1).Resize(, c1).Value
For j = 20 To c1
If arr(1, j) > 0 Then
If Len(x) > 0 Then
If 待着色 Is Nothing Then
Set 待着色 = Cells(r, j)
Else
Set 待着色 = Union(待着色, Cells(r, j))
End If
Else
If 不着色 Is Nothing Then
Set 不着色 = Cells(r, j)
Else
Set 不着色 = Union(不着色, Cells(r, j))
End If
End If
End If
Next
If Not 待着色 Is Nothing Then 待着色.Interior.Color = vbBlue
If Not 不着色 Is Nothing Then 不着色.Interior.Pattern = xlPatternNone
Set 待着色 = Nothing
Set 不着色 = Nothing
Application.EnableEvents = True
End If
End Sub
|
评分
-
1
查看全部评分
-
|