我正在重寫此答案,因爲需求需要迭代爲範圍中的每個單元格定義的任何FormatCondition以及其他單元格值。可以找到一個簡潔的方法,例如,here。基本上它由以下部分組成:
For X = 1 To Cell.FormatConditions.Count
With Cell.FormatConditions(X)
If .Type = xlCellValue Then
...
If CellInterior Then
DisplayedColor = IIf(ReturnColorIndex, Cell.Interior.ColorIndex, Cell.Interior.Color)
Else
DisplayedColor = IIf(ReturnColorIndex, Cell.Font.ColorIndex, Cell.Font.Color)
探索單元格的不同方式來定義填充顏色。
所以,你應該在範圍迭代
Dim rng As Range, cell As Range
Set rng = Range("M500:M550")
For Each cell In rng
rem check the filling with the method in the link
rem if it's the colorindex you want
rem cell.Value = ''
rem Also, get the row number and delete content of range ("C5XX")
Next cell
宏刪除取決於填充顏色的單元? – Alfabravo
是的,這是我得到的主要問題。 –
但是!我希望它刪除讓我們說M500和C500在同一時間,根據M500顏色 –