2012-11-26 185 views

回答

0

E列是您的姓名和列A的開頭:B是名稱&顏色查找。根據需要將這些更改爲命名範圍/其他表。

Sub ColourCheck() 

    Dim cell As Range 
    Dim cellColour As String 

    For Each cell In Sheet1.Range("E1").CurrentRegion.Rows 

     cellColour = Application.WorksheetFunction.VLookup(cell.Value, Sheet1.Range("A1").CurrentRegion, 2, 0) 

     Select Case cellColour 

      Case "red":  cell.Interior.ColorIndex = 3 
      Case "blue": cell.Interior.ColorIndex = 5 

     End Select 

    Next cell 

End Sub 
相關問題