Puuh. Nu har jeg lavet det, men den er godt nok laaangsom. Derfor har jeg lavet det til en knap istedet..
Public Function GetProgress(ByVal objSheet As Excel.Worksheet, ByVal varColor As Long)
Dim oCell As Excel.Range
Dim oSheet As Excel.Worksheet
Dim intCounter As Integer
intCounter = 0
Set oSheet = objSheet
For Each oCell In oSheet.Range("A:A")
' On Error Resume Next
If oCell.Interior.Color = varColor Then
intCounter = intCounter + 1
End If
Next
Set oSheet = Nothing
Set oCell = Nothing
GetProgress = intCounter
End Function
Public Sub Update()
Dim oSheet As Excel.Worksheet
Dim intCount As Integer
Application.EnableEvents = False
For Each oSheet In Application.Worksheets
If Not oSheet.Name = "Status" Then
Select Case oSheet.Name
Case "JRV"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C3").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D3").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E3").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F3").Value = intCount
Case "ELS"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C4").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D4").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E4").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F4").Value = intCount
Case "LVT"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C5").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D5").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E5").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F5").Value = intCount
Case "LBI"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C6").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D6").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E6").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F6").Value = intCount
Case "RTH"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C7").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D7").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E7").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F7").Value = intCount
Case "SUFI"
' tæller rød
intCount = GetProgress(oSheet, vbRed)
Range("Status!C8").Value = intCount
' tæller gul
intCount = GetProgress(oSheet, vbYellow)
Range("Status!D8").Value = intCount
' tæller blå
intCount = GetProgress(oSheet, vbBlue)
Range("Status!E8").Value = intCount
' tæller grøn
intCount = GetProgress(oSheet, vbGreen)
Range("Status!F8").Value = intCount
End Select
End If
Next
Application.EnableEvents = True
Set oSheet = Nothing
End Sub