Dim Ur(3) As Range, Cx%, Cv%, Crr
Crr = Array(0, 38, 40, 39)
.Range("AP2:AP127").Replace "大", "小"
For Each Rng In .Range("AP2:AP127")
Cx = Rng.Interior.ColorIndex
Cv = Switch(Cx = 44, 1, Cx = 4, 2, Cx = 8, 3, Cx = Cx, 0)
If Ur(Cv) Is Nothing Then Set Ur(Cv) = Rng Else Set Ur(Cv) = Union(Ur(Cv), Rng)
For i = 1 To 3
If Not Ur(Cv) Is Nothing Then Ur(Cv).Interior.ColorIndex = Crr(i)
Next i
Next
.Range("AX2:BB127").Replace "小", "大"
[AP2:BC127].Copy [BE2]
更正:
Dim Ur(3) As Range, Cx%, Cv%, Crr
Crr = Array(0, 38, 40, 39)
.Range("AP2:AP127").Replace "大", "小"
For Each Rng In .Range("AP2:AP127")
Cx = Rng.Interior.ColorIndex
Cv = Switch(Cx = 44, 1, Cx = 4, 2, Cx = 8, 3, Cx = Cx, 0)
If Ur(Cv) Is Nothing Then Set Ur(Cv) = Rng Else Set Ur(Cv) = Union(Ur(Cv), Rng)
Next
For i = 1 To 3 '這一段要從上方迴圈抓出來
If Not Ur(Cv) Is Nothing Then Ur(Cv).Interior.ColorIndex = Crr(i)
Next i
.Range("AX2:BB127").Replace "小", "大"
[AP2:BC127].Copy [BE2]作者: ziv976688 時間: 2019-8-29 11:29