Sub 檢查_含有格式化條件數量()
Dim uR As Range, formatcoN&, formatcoAD$, msg$, formatcoRng As Range
Dim orinColor&, disinColor&, orfoColor&, disfoColor&
Dim newinColor&, newdisinColor&, newfoColor&, newdisfoColor&, diF&
For Each uR In check_Area.SpecialCells(2)
diF = 0
orinColor = uR.Interior.ColorIndex
disinColor = uR.DisplayFormat.Interior.ColorIndex
If orinColor <> disinColor Then
diF = 1
GoTo 9
Else
If disinColor = -4142 Then
disinColor = 1
End If
uR.Interior.ColorIndex = disinColor + 1
newinColor = uR.Interior.ColorIndex
newdisinColor = uR.DisplayFormat.Interior.ColorIndex
uR.Interior.ColorIndex = orinColor
If newinColor <> newdisinColor Then
diF = 1
GoTo 9
End If
End If
orfoColor = uR.Font.ColorIndex
disfoColor = uR.DisplayFormat.Font.ColorIndex
If orfoColor <> disfoColor Then
diF = 1
GoTo 9
Else
If disfoColor = -4105 Then
disfoColor = 1
End If
uR.Font.ColorIndex = disfoColor + 1
newfoColor = uR.Font.ColorIndex
newdisfoColor = uR.DisplayFormat.Font.ColorIndex
uR.Font.ColorIndex = orfoColor
If newfoColor <> newdisfoColor Then
diF = 1
GoTo 9
End If
End If
9: If diF = 1 Then
formatcoN = formatcoN + 1
If formatcoAD = "" Then
formatcoAD = uR.Address
Else
formatcoAD = formatcoAD & "," & uR.Address
End If
End If
Next
If formatcoN > 20 Then
msg = "格式化條件太多!不顯示格位"
ElseIf formatcoN <> 0 Then
msg = "有格式化條件儲存格格位: " & formatcoAD
Else
msg = "沒有 格式化條件"
End If
Option Explicit
Sub 檢查_格式化條件數量_1() 'FormatConditions.Count
Dim msg As String, foco As Range
On Error Resume Next
For Each foco In Cells.SpecialCells(2)
With foco.FormatConditions.Add(xlCellValue, xlGreater, "")
msg = msg & foco.Address
End With
Next
If msg = "" Then msg = ActiveSheet.Name & " 沒有任何 格式化條件...."
MsgBox msg
End Sub作者: Andy2483 時間: 2020-8-13 19:52