Seite 1 von 1
Bedingte Formatierung
Verfasst: Mo, 26.01.2009 18:19
von navy-cis
Hi Leute
wie kann ich heraus bekommen welche Bedingte Formatierung angewendet wird und das per Macro?
Also ich habe 3 Bedingungen
1) istGleich 0 weiß
2) D9>D8 grün
3) D9<D8 rot
Jetzt möchte ich abfragen ob D9 rot ist. Mit ConditionalFormat komme ich nicht weiter, das auflisten der Bedingungen ist nicht das was ich suche.
Ich hoffe es kann mir jemand helfen.
Gruß navy-cis
Re: Bedingte Formatierung
Verfasst: Mo, 26.01.2009 18:32
von Karolus
Hallo
Was hälst du von einem pragmatischem:
(Achtung Pseudocode)
if D9 < D8 then
zustand = "rot"
end if
if D9 > D8 then
zustand = "grün"
end if
...
Gruß Karo
Re: Bedingte Formatierung
Verfasst: Mo, 26.01.2009 20:33
von navy-cis
Hi Karo
vielen Dank für die schnelle Antwort, leider ist dein Vorschlag nicht das was ich suche.
Das Beispiel das ich benutzt habe ist nur eine Zelle ich. In meinem Prog. frage ich 20 Zellen ab.
Ich hatte da er an so etwas gedacht.
Code: Alles auswählen
Sub bedingteFormateEinerZelleAnzeigen
' Variablen deklarieren
Dim oZelle as Object
Dim oBedingtesFormat as Object
Dim nCounter as Integer
Dim sAusgabe as String
' Zelle A1 holen
oZelle = ThisComponent.Sheets(2).getCellByPosition( 5, 8 )
' Schleife durch alle bedingten Formate
For nCounter = 0 To oZelle.ConditionalFormat.Count-1
' bedingtes Formate holen
oBedingtesFormat = oZelle.ConditionalFormat(nCounter)
' Ausgabe der Eigenschaften
sAusgabe = (nCounter+1) & ". Bedingtes Format:" & chr(13)
sAusgabe = sAusgabe & "Operator: " & _
oBedingtesFormat.Operator & chr(13)
sAusgabe = sAusgabe & "Formel 1: " & _
oBedingtesFormat.Formula1 & chr(13)
sAusgabe = sAusgabe & "Formel 2: " & _
oBedingtesFormat.Formula2 & chr(13)
sAusgabe = sAusgabe & "Formatvorlage: " & _
oBedingtesFormat.StyleName & chr(13)
' Ausgabe anzeigen
MsgBox sAusgabe
Next nCounter
End Sub
ich würde gerne den StyleName abfragen. Damit ich das ganze in einer Schleife laufen lassen kann.
Gruß navy-cis