More elegant way of replacing text and formatting it

前端 未结 2 1023
庸人自扰
庸人自扰 2021-01-14 15:58

Right now I have this:

[M3].select \'Range(\"M3\").Select originally, I like using the [ ] notation
totalrows = [H2].CurrentRegion.Rows.Count
Range(\"m3:p\"          


        
2条回答
  •  悲&欢浪女
    2021-01-14 16:11

    If the cell contains the text "Green", change the cell background to Green and don't change the text.

    I'd use this which I think is elegant enough:

    [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
    

    Not one liner though.

提交回复
热议问题