现在我有一个:
[M3].select 'Range("M3").Select originally, I like using the [ ] notation
totalrows = [H2].CurrentRegion.Rows.Count
Range("m3:p" & totalrows).Select
[m2].Activate
'Green
With Application.ReplaceFormat.Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
End With
Selection.Replace What:="Green", Replacement:="Red", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True有什么更优雅的方法来完成这个任务吗?
我今天发现了这一点,我喜欢它的简单性,并将它合并到处理文本替换的其他部分中。
[M:P].Replace "Green", "Red", xlPart但是,有一种简单的方法可以用这样的简单语句将细胞背景颜色设置为绿色吗?如果单元格包含文本“绿色”,则将单元格背景更改为“绿色”,不更改文本。谢谢你的建议!
发布于 2014-05-20 06:54:15
If the cell contains the text "Green", change the cell background to Green and don't change the text.
我会用它,我认为它足够优雅:
[A1].FormatConditions.Add xlExpression, , "=A1=""Green"""
With [A1].FormatConditions(1)
.Interior.Color = RGB(0, 255, 0)
.ModifyAppliesToRange [M:P] '~~> of course change this part to suit
End With不过,没有一条班轮。
https://stackoverflow.com/questions/22513772
复制相似问题