AW: VBA Überschrift suchen, Zellen färben
20.06.2015 11:21:31
Gerd
Servus Walter!
Sub betingte_Formatierung()
Dim Q As Worksheet, Z As Worksheet
Dim Bereich As Range
Dim objZelle As Range
Dim w As String
Dim nr As Variant
Set Q = Worksheets("Tabelle1")
Set Z = Worksheets("Tabelle2")
w = Q.Range("B4")
nr = Application.Match(w, Z.Rows(1), 0)
If Not IsNumeric(nr) Then
MsgBox "Spaltenuebrschrift mit Suchtext nicht gefunden!", vbInformation
Exit Sub
End If
Set Bereich = Z.Range(Z.Cells(1, nr), Z.Cells(Z.Rows.Count, nr).End(xlUp))
For Each objZelle In Bereich
Select Case objZelle.Value
Case "Apfel": objZelle.Interior.ColorIndex = 6
Case "Birne": objZelle.Interior.ColorIndex = 37
Case "Tomate": objZelle.Interior.ColorIndex = 40
End Select
Next
End Sub
Gruß Gerd