Sub PaintIt()
Const C_Sheet As String = "Tabelle1"
Const C_StartAdrress As String = "A1"
Dim oWsh As Excel.Worksheet
Dim oRange As Range, oRow As Range, oCell As Range
   Application.ScreenUpdating = False
   
   'the sheet
   Set oWsh = ThisWorkbook.Sheets(C_Sheet)
   'the matrix
   With oWsh
      Set oRange = .Range(.Range(C_StartAdrress), .Range(C_StartAdrress).Offset(39, 39))
      With oRange.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
      End With
      For Each oRow In oRange.Rows
         For Each oCell In oRow.Cells
            'PaintIt
            Select Case oCell.Value
            'Alle Werte <0,2 (grün), 2. Alle Werte zwischen 0,2 und 0,35 (gelb), 3. Alle Werte zwischen 0,35 und 0,5 (orange) und 4. Alle Werte >= 0,5 (rot).
               Case Is < 0.2
                  oCell.Interior.Color = 5287936
               Case Is >= 0.5
                  oCell.Interior.Color = 255
               Case 0.2 To 0.35
                  oCell.Interior.Color = 65535
               Case Else
                  oCell.Interior.Color = 49407
            End Select
         Next oCell
      Next oRow
   End With
   Set oWsh = Nothing
   Application.ScreenUpdating = True
   
End Sub
	Sub AssignIt() 
	Const C_Sheet As String = "Tabelle1" 
	Const C_StartAdrress As String = "A1" 
	 
	Dim oWsh As Excel.Worksheet 
	Dim oRange As Range, oRow As Range, oCell As Range 
	Dim rngGreen As Range, rngYellow As Range, rngOrange As Range, rngRed As Range 
	Dim x As Long 
	 
	   Application.ScreenUpdating = False 
	    
	   'the sheet 
	   Set oWsh = ThisWorkbook.Sheets(C_Sheet) 
	 
	   'the matrix 
	   With oWsh 
	      Set oRange = .Range(.Range(C_StartAdrress), .Range(C_StartAdrress).Offset(39, 39)) 
	       
	      For Each oRow In oRange.Rows 
	         'ClearIt 
	         Set rngGreen = Nothing 
	         Set rngYellow = Nothing 
	         Set rngOrange = Nothing 
	         Set rngRed = Nothing 
	         For Each oCell In oRow.Cells 
	            'CollectIt 
	            Select Case oCell.Value 
	            'Alle Werte <0,2 (grün), 2. Alle Werte zwischen 0,2 und 0,35 (gelb), 3. Alle Werte zwischen 0,35 und 0,5 (orange) und 4. Alle Werte >= 0,5 (rot). 
	               Case Is < 0.2 
	                  If Not rngGreen Is Nothing Then 
	                     Set rngGreen = Union(rngGreen, oCell) 
	                  Else 
	                     Set rngGreen = oCell 
	                  End If 
	               Case Is >= 0.5 
	                  If Not rngRed Is Nothing Then 
	                     Set rngRed = Union(rngRed, oCell) 
	                  Else 
	                     Set rngRed = oCell 
	                  End If 
	               Case 0.2 To 0.35 
	                  If Not rngYellow Is Nothing Then 
	                     Set rngYellow = Union(rngYellow, oCell) 
	                  Else 
	                     Set rngYellow = oCell 
	                  End If 
	               Case Else 
	                  If Not rngOrange Is Nothing Then 
	                     Set rngOrange = Union(rngOrange, oCell) 
	                  Else 
	                     Set rngOrange = oCell 
	                  End If 
	            End Select 
	         Next oCell 
	          
	         '*************************************************************************** 
	         'ForFurtherUse 
	         Debug.Print rngGreen.Address 
	         Debug.Print WorksheetFunction.Min(rngGreen), WorksheetFunction.Max(rngGreen) 
	         Debug.Print WorksheetFunction.Median(rngGreen) 
	         'WorksheetFunction.Quartile Method 
	         For x = 0 To 4 
	            Debug.Print WorksheetFunction.Quartile(rngGreen, x) 
	         Next x 
	         '*************************************************************************** 
	       
	      Next oRow 
	   End With 
	   Set oWsh = Nothing 
	   Application.ScreenUpdating = True 
	    
	End Sub 
     |