ich möchte per vba "Bedingte Formatierungen" editieren bzw. erzeugen.
Grundsätzlich funktioniert das auch, nur wird der relative Bezug in der Formel "I113" verändert - oft auf einen Werte über 10000 (WENN(ISTZAHL(SUCHEN(""["";I113))=WAHR;-1;0)").
Ich benötige den relativen Bezug, absolut ist keine alternative.
Kann sich jemand vorstellen an was das liegt?
Sub FormCondition()
Dim ws As Worksheet
Dim fcd As FormatCondition
Dim fcds As FormatConditions
Dim rng As Range
Dim i As Long
Dim arrAdress() As String
Set ws = shtContent
Set rng = Range(ws.Cells(), ws.Cells())
For Each fcd In rng.FormatConditions
ReDim Preserve arrAdress(i)
arrAdress(i) = fcd.AppliesTo.Address
i = i + 1
Next fcd
For Each fcd In rng.FormatConditions
fcd.Delete
Next fcd
For i = 0 To UBound(arrAdress)
Set rng = Range(arrAdress(i))
If i = 0 Then
Set fcd = rng.FormatConditions.Add(Type:=xlExpression, Formula1:= _
"=WENN(ISTFEHLER(WENN(FEHLER.TYP(cbo_SubPosition_Teilehandhabung);0;1));0;1)" _ _
& "+WENN(ISTZAHL(SUCHEN(""["";I113))=WAHR;-1;0)")
fcd.Borders.LineStyle = xlLineStyleNone
fcd.Font.Color = RGB(255, 255, 255)
fcd.Interior.Color = RGB(255, 255, 255)
fcd.Priority = i + 1
fcd.StopIfTrue = False
End If
Next i
Set fcd = Nothing
Set fcds = Nothing
Set rng = Nothing
Set ws = Nothing
End Sub