Bedingte Formatierung

Das Tabellenkalkulationsprogramm

Moderator: Moderatoren

Benutzeravatar
navy-cis
*
Beiträge: 12
Registriert: Mo, 26.01.2009 17:54

Bedingte Formatierung

Beitrag 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
LG n-cis
Karolus
********
Beiträge: 7519
Registriert: Mo, 02.01.2006 19:48

Re: Bedingte Formatierung

Beitrag 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
LO7.4.7.2 debian 12(bookworm) auf Raspberry4b 8GB (64bit)
LO24.8.2.1 flatpak debian 12(bookworm) auf Raspberry4b 8GB (64bit)
Benutzeravatar
navy-cis
*
Beiträge: 12
Registriert: Mo, 26.01.2009 17:54

Re: Bedingte Formatierung

Beitrag 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
LG n-cis
Antworten