ich habe VBA Makro, welches die erste Reihe eine Tabelle nach dem Text "PLT" durchsucht und dann diese Spalte markiert (von 2 bis 9999) und eine bedingte Formatierung einfügt. Das funktioniert auch soweit gut.
Problem: Das ganze funktioniert aber nur, wenn die zu formatierenden Daten in Reihe "F" stehen.
Frage: Wie ändere ich die Formel so, dass egal wo die PLT Daten stehen, die bedingte Formatierung greift?
Hier die Tabelle zum besseren Verständnis.
https://www.herber.de/bbs/user/108624.xlsm
Danke im Voraus
Gruß, Nik
Sub AAA()
Dim c As Range
Set c = Rows(1).Find("*PLT*", LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
Range(Cells(2, c.Column), Cells(9999, c.Column)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
' Bedingte Formatierung anlegen
.FormatConditions.Delete
' Bedingung für grünen Zellhintergrund
With .FormatConditions.Add(Type:=xlExpression, Formula1:="=ODER($F2=""AS"";$F2=""BH" _
";$F2=""BM"";$F2=""BO"")")
.Interior.ColorIndex = 43
End With
' Bedingung für blauen Zellhintergrund
With .FormatConditions.Add(Type:=xlExpression, Formula1:="=ODER($F2=""FA"";$F2=""FC" _
";$F2=""SL"")")
.Interior.ColorIndex = 37
End With
' Bedingung für gelben Zellhintergrund
With .FormatConditions.Add(Type:=xlExpression, Formula1:="=ODER($F2=""BI"";$F2=""BN" _
";$F2=""BT"")")
.Interior.ColorIndex = 6
End With
End With
Else
MsgBox "PLT wurde nicht gefunden"
End If
End Sub