如果excel中的任何单元格为空,则突出显示整行

时间:2017-03-27 07:39:37

标签: excel-formula conditional-formatting

我有来自A:AD的数据。即使A:AD中的任何单元格为空,我也需要将整行突出显示为灰色。

1 个答案:

答案 0 :(得分:0)

试试这个,

Private Sub Worksheet_Change(ByVal Target As Range)   //Change this range 
Set MyPlage = Range("YourRange") //Change this range 

For Each Cell In MyPlage  

    Select Case Cell.Value  

     Case Is = "Withdrawn"  
        Cell.EntireRow.Interior.ColorIndex = 7  

    Case Is = "Postponed"  
        Cell.EntireRow.Interior.ColorIndex = 8  

    Case Is = "Terms Agreed"  
        Cell.EntireRow.Interior.ColorIndex = 4  

    Case Is = "Papers Rec"  
        Cell.EntireRow.Interior.ColorIndex = 3  

    Case Else  
        Cell.EntireRow.Interior.ColorIndex = xlNone  

    End Select  

Next  
End Sub

http://ccm.net/faq/8847-excel-vba-a-macro-to-change-the-color-of-a-row http://dmcritchie.mvps.org/excel/colors.htm