问题
If a cell is conditionally formatted I can't simply change the interior color index by cells(row , col).interior.colorindex = 6
I tried this but the format of the cell is lost
val = wRes.Cells(i, p)
wRes.Cells(i, p).Clear
wRes.Cells(i, p).Interior.ColorIndex = 6
wRes.Cells(i, p) = val
like certain cells have dates and other have numbers in "00,000" this format are lost.
回答1:
Use,
wRes.Cells(i, p).FormatConditions.Delete
... to reshape the Applies to: range of existing Conditional Formatting to exclude the cell you want to change.
来源:https://stackoverflow.com/questions/38554685/how-to-change-the-interior-colorindex-of-a-conditionally-formatted-cell