|
这段vba写的有些简陋,基本实现了功能
Sub run()
Row = Range("b65536").End(xlUp).Row
k = countR
a = 0
Dim i As Integer
Dim j As Integer
init = 2
For c = 2 To k
If Cells(c, 1) & Cells(c, 2) <> Cells(c + 1, 1) & Cells(c + 1, 2) Then
j = c
i = init
If a = 0 Then
Call draw1(i, j)
a = 1
Else
Call draw2(i, j)
a = 0
End If
enter = 1
temp = c
End If
If enter = 1 Then
init = temp + 1
temp = 0
enter = 0
End If
Next c
End Sub
Function draw1(i, j As Integer)
Range(Cells(i, 1), Cells(j, 11)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.5
.PatternTintAndShade = 0
End With
End Function
Function draw2(i, j As Integer)
Range(Cells(i, 1), Cells(j, 11)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.1
.PatternTintAndShade = 0
End With
End Function
Function countR() As Integer
For i = 2 To Range("a65536").End(xlUp).Row
If Sheets(1).Cells(i, 1) <> "" Then
countR = i
Else
Exit For
End If
Next i
End Function
|
|