VBA-Programmierung in Microsoft Excel

Tutorial: Excel-Beispiele

Zellen in Abhängigkeit des Summen-Teilergebnisses markieren

Gruppe

Feature

Bereich

Bedingt

Thema

Zellen in Abhängigkeit des Summen-Teilergebnisses markieren

Problem

Alle Werte in Spalte B, bei denen das Summen-Teilergebnis größer/gleich 5 ist, sollen farblich hervorgehoben werden.

Lösung

Darstellung nur anhand einer Beispielarbeitsmappe möglich.




ClassModule: Tabelle1

Private Sub Worksheet_Calculate()
   Select Case Hour(Time)
      Case 22 To 24, 0 To 6
         With Range("A1")
            .Borders(xlDiagonalDown).Weight = xlThin
            .Borders(xlDiagonalUp).Weight = xlThin
         End With
         With Range("B1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
         With Range("C1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
      Case 6 To 14
         With Range("B1")
            .Borders(xlDiagonalDown).Weight = xlThin
            .Borders(xlDiagonalUp).Weight = xlThin
         End With
         With Range("A1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
         With Range("C1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
      Case 14 To 22
         With Range("C1")
            .Borders(xlDiagonalDown).Weight = xlThin
            .Borders(xlDiagonalUp).Weight = xlThin
         End With
         With Range("A1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
         With Range("B1")
            .Borders(xlDiagonalDown).LineStyle = xlNone
            .Borders(xlDiagonalUp).LineStyle = xlNone
         End With
   End Select
End Sub

    


Beiträge aus dem Excel-Forum zu den Themen Feature und Bedingt