- 帖子
- 2848
- 主題
- 10
- 精華
- 0
- 積分
- 2903
- 點名
- 0
- 作業系統
- 〔略〕
- 軟體版本
- 〔略〕
- 閱讀權限
- 100
- 性別
- 男
- 來自
- 〔略〕
- 註冊時間
- 2013-5-13
- 最後登錄
- 2026-7-25
|
Sub ifcolor_1()
Dim R&, C&, xR As Range, Cv%, Cr, i&, j%
R = Cells(Rows.Count, 2).End(xlUp).Row
C = Cells(2, Columns.Count).End(xlToLeft).Column
Cr = Array(16, 48, 15) '橫向的色號(自行更改)
With [B2].Resize(R - 1, C - 1)
.Interior.ColorIndex = xlNone: .Font.Bold = False
For Each xR In .Rows(1).Cells
Cv = Switch(xR = "目標", 34, xR = "達成", 33, xR = xR, 0) '縱向的色號(自行更改)
If Cv > 0 Then
With xR.Resize(R - 1): .Interior.ColorIndex = Cv: .Font.Bold = True: End With
End If
Next
For i = 2 To R - 1: For j = 1 To 3
If .Cells(i, j) = "All" Then
With .Cells(i, j).Resize(1, C - j)
.Interior.ColorIndex = Cr(j - 1): .Font.Bold = True
End With
Exit For
End If
Next: Next
End With
End Sub |
|