Home VBA Makro Beispiele Formatierungen VBA - Art bedingte Formatierung
VBA - Art bedingte Formatierung PDF Drucken E-Mail
Geschrieben von: Marcus Rose   
Sonntag, 11. Mai 2008 um 22:57 Uhr

Auf diese Art kann man Zellen mit mehr als 3 Formatierungen versehen, was ja so ohne weiteres nicht mit Excel möglich ist. Excel VBA hilft us hier mit verschiedenen Möglichkeiten der Programmierung. An dieser Stelle gebe ich Euch 2 Beispiele zur Lösung. Beide Lösungswege bewerkstelligen, dass die abgebildete Tabelle mit Buchstaben in verschiedenen Farben dargestellt werden können.

 

 
 ABCDEFGH
1 MontagDienstagMittwochDonnerstagFreitagSamstagSonntag
2Name 1X      
3Name 2 L     
4Name 3  T    
5Name 4   R   
6Name 5    E  
7Name 6     F 
8Name 7      F
9Name 8       
10Name 9       
 


Möglichkeit 1:


Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Dim cell As Range
    For Each cell In Range("B2:H10")
    If cell.Value = "X" Then cell.Font.ColorIndex = 15
    If cell.Value = "L" Then cell.Font.ColorIndex = 3
    If cell.Value = "T" Then cell.Font.ColorIndex = 41
    If cell.Value = "R" Then cell.Font.ColorIndex = 10
    If cell.Value = "R" Then cell.Font.FontStyle = "Fett"
    If cell.Value = "E" Then cell.Font.ColorIndex = 15
    If cell.Value = "F" Then cell.Font.ColorIndex = 3
    If cell.Value = "D" Then cell.Interior.ColorIndex = 3
    If cell.Value = "" Then cell.Clear
    Next
End Sub

Möglichkeit 2:


Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Dim cell As Range
    For Each cell In Range("B2:H10")
        Select Case cell
            Case Is = "X"
                cell.Font.ColorIndex = 15
            Case Is = "L"
                cell.Font.ColorIndex = 3
            Case Is = "T"
                cell.Font.ColorIndex = 41
            Case Is = "R"
                cell.Font.FontStyle = "Fett"
                cell.Font.ColorIndex = 10
            Case Is = "E"
                cell.Font.ColorIndex = 26
            Case Is = "F"
                cell.Font.ColorIndex = 47
            Case Is = "D"
                cell.Interior.ColorIndex = 47
            Case Is = ""
                cell.Clear
        End Select
    Next
End Sub

 
Copyright © 2012 ms-excel.eu. Alle Rechte vorbehalten.
 

Autoren - Login

Werbung

wichtige Links:
http://ms-excel.eu
Hier habt Ihr eine gute Excel Hilfe
Besucherstatistik
Besucher gesamt: 1.314.655
Besucher heute: 345
Besucher gestern: 2.928
Max. Besucher pro Tag: 3.367
gerade online: 1
max. online: 85
counter Statistiken