Function BedingungAdd(Zellen As Range, farbe As Integer) As Double
Dim Zelle As Range
Dim farben As Integer
Application.Volatile
For Each Zelle In Zellen
farben = GetCellColor(Zelle)
If farben = farbe Then
BedingungAdd = BedingungAdd + Zelle.Value
End If
Next
End Function
Function GetCellColor(cell As Range) As IntegerDim iDim myValDim myColor As IntegerDim done As BooleanOn Error Resume NextNames("testname").DeleteOn Error GoTo 0Application.ReferenceStyle = xlR1C1myVal = cell.ValuemyColor = cell.Interior.ColorIndexdone = FalseFor i = 1 To cell.FormatConditions.CountWith cell.FormatConditions.Item(i)If .Type = 1 ThenSelect Case .OperatorCase xlBetweenIf (myVal >= Evaluate(.Formula1) And myVal <= Evaluate(.Formula2)) _Or (myVal <= Evaluate(.Formula1) And myVal >= Evaluate(.Formula2)) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlEqualIf myVal = Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlGreaterIf myVal > Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlGreaterEqualIf myVal >= Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlLessIf myVal < Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlLessEqualIf myVal <= Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlNotBetweenIf myVal < Evaluate(.Formula1) Or myVal > Evaluate(.Formula2) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfCase xlNotEqualIf myVal <> Evaluate(.Formula1) ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfEnd SelectElseIf .Type = 2 ThenNames.Add Name:="testname", RefersToR1C1Local:=.Formula1If Evaluate("testname") ThenmyColor = .Interior.ColorIndexdone = TrueEnd IfNames("testname").DeleteElseMsgBox "Unbekannter Typ: " & .Type, , "PANIC: In Function GetCellColor"Exit FunctionEnd IfEnd WithIf done Then Exit ForNextApplication.ReferenceStyle = xlA1GetCellColor = myColorEnd FunctionFunction BedingungAdd(Zellen As Range, farbe As Integer) As Double
Dim Zelle As Range
Dim farben As Integer
Application.Volatile
For Each Zelle In Zellen
farben = GetCellColor(Zelle)
If farben = farbe Then
BedingungAdd = BedingungAdd + Zelle.Value
End If
Next
End FunctionFunction GetCellColor(cell As Range) As Integer
Dim i
Dim myVal
Dim myColor As Integer
Dim done As Boolean
On Error Resume Next
On Error GoTo 0
Application.ReferenceStyle = xlR1C1
myVal = cell.Value
myColor = cell.Interior.ColorIndex
done = False
For i = 1 To cell.FormatConditions.Count
With cell.FormatConditions.Item(i)
If .Type = 1 Then
Select Case .Operator
Case xlBetween
If (myVal >= Evaluate(.Formula1) And myVal <= Evaluate(.Formula2)) _
Or (myVal <= Evaluate(.Formula1) And myVal >= Evaluate(.Formula2)) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlEqual
If myVal = Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlGreater
If myVal > Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlGreaterEqual
If myVal >= Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlLess
If myVal < Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlLessEqual
If myVal <= Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlNotBetween
If myVal < Evaluate(.Formula1) Or myVal > Evaluate(.Formula2) Then
myColor = .Interior.ColorIndex
done = True
End If
Case xlNotEqual
If myVal <> Evaluate(.Formula1) Then
myColor = .Interior.ColorIndex
done = True
End If
End Select
End If
End With
If done Then Exit For
Next
Application.ReferenceStyle = xlA1
GetCellColor = myColor
End Function
access datenbank mittels html auslesen
matzew 31.05.2007 - 254 Hits - 6 Antworten
Festplatte auslesen
Gast4816 24.08.2007 - 234 Hits - 5 Antworten
standardspeicherort auslesen
Tomschi 05.09.2007 - 55 Hits - 2 Antworten
VB - Dateiattribute auslesen
MaLi 12.02.2008 - 260 Hits - 1 Antwort
seriennummer auslesen
Sigurd 11.11.2007 - 1625 Hits - 1 Antwort