2016-04-22 145 views
-3

Picture of some data條件格式

這裏我的要求 1.只是最低值每的每一行會改變它的顏色在藍色(如果最低值是在不止一個小區) 2.如果最低值只有一種顏色,單元格具有黃色。

這些都是隻有每個行中具有最低值的單元完成的。

+1

你有什麼具體問題? – flohdieter

+1

請提供一個問題,你有什麼問題,你有什麼嘗試?你有沒有寫過代碼? –

+0

在主頁選項卡上,您可以找到條件格式。如果你看看它,一切都會變得清晰 –

回答

0

我在下面創建的公式是爲列A到N設置的,根據需要進行調整。

有條件格式的單元格A1(根據需要進行調整)與這兩個規則:


=IF(IF(A1=SMALL($A1:$N1,1),COUNTIF($A1:$N1,SMALL($A1:$N1,1)),0)>=2,1,0) 

標記此一個與「停止如果爲True」和顏色背景黃色。對於同一小區


下一條規則:

=IF(A1=SMALL($A1:$N1,1),1,0) 

顏色的背景藍色。


使用格式刷的規則複製到該行中的其他細胞。

單元現在應該根據需要更改背景顏色。

0

試試看。這不是完美的,但應該做你想做的。

Sub ConditionalFormat() 

    With Application 
     .ScreenUpdating = False 
     .Calculation = xlCalculationManual 
    End With 

    Dim ws As Worksheet 
    Dim x As Integer, u As Integer, myCount As Integer 
    Dim lRow As Long, lColumn As Long 
    Dim myMin As Double 
    Set ws = Worksheets("Sheet1") 

    With ws 
     'Count last row 
     lRow = .Cells.Find(What:="*", _ 
      After:=.Cells(1, 1), _ 
      LookAt:=xlPart, _ 
      LookIn:=xlFormulas, _ 
      SearchOrder:=xlByRows, _ 
      SearchDirection:=xlPrevious, _ 
      MatchCase:=False).Row 
     'Count last column 
     lColumn = .Cells.Find(What:="*", _ 
      After:=.Cells(1, 1), _ 
      LookAt:=xlPart, _ 
      LookIn:=xlFormulas, _ 
      SearchOrder:=xlByColumns, _ 
      SearchDirection:=xlPrevious, _ 
      MatchCase:=False).Column 
     'Remove currency numberformat 
     .Range(.Cells(1, 1), .Cells(lRow, lColumn)).NumberFormat = "General" 

     For x = 1 To lRow 
      'Find smallest value and count how many times it shows up 
      myMin = Application.WorksheetFunction.Min(.Rows(x)) 
      myCount = Application.WorksheetFunction.CountIf(.Rows(x), myMin) 
      'Color cells that appear more than once blue 
      If myCount > 1 Then 
       For u = 1 To lColumn 
        If .Cells(x, u).Value = myMin Then 
         .Cells(x, u).Interior.Color = 15773696 
        End If 
       Next u 
      'Color cells that appear once yellow 
      ElseIf myCount = 1 Then 
       For u = 1 To lColumn 
        If .Cells(x, u).Value = myMin Then 
         .Cells(x, u).Interior.Color = 65535 
         Exit For 
        End If 
       Next u 
      End If 
     Next x 
    'Return currency format 
    .Range(.Cells(1, 1), .Cells(lRow, lColumn)).NumberFormat = "[$£-809]#,##0.00" 

    End With 

    With Application 
     .ScreenUpdating = True 
     .Calculation = xlCalculationAutomatic 
    End With 

End Sub