Bedingtform. ListObjects -> Spaltenname
04.01.2023 08:50:26
Mathias
Es wäre sehr nett wenn mir jemand weiterhelfen könnte. Ich möchte bedinget Formatierungen über VBA setzen das funktioniert auch gut der CodE wird bei jedem speichern ausgeführt aber.
Ist es möglich über den Spalten Namen (also die Überschrift wie zbsp Datum) einer Tabelle(ListObjects) bedingt zu formatieren. Im Moment mache ich es über die Nummer der Spalte. Nur leider werden immer wieder Spalten in ihrer Position innerhalb der Tabelle durch meinen Chef aus Bequemlichkeit verschoben oder Leerzeilen über der Tabelle eingefügt. Ich darf die Tabelle allerdings nicht Sperren.
so mache ich es im derzeit:
ActiveSheet.Cells.FormatConditions.Delete
With wsAktiv.ListObjects(1).ListColumns(12)
.DataBodyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=ISTLEER($L2)=WAHR"
.DataBodyRange.FormatConditions(.DataBodyRange.FormatConditions.Count).SetFirstPriority
With .DataBodyRange.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.799981688894314
End With
.DataBodyRange.FormatConditions(1).StopIfTrue = False
End With
With wsAktiv.ListObjects(1).ListColumns(13)
.DataBodyRange.FormatConditions.Add Type:=xlExpression, Formula1:="=ISTLEER($M2)=WAHR"
.DataBodyRange.FormatConditions(.DataBodyRange.FormatConditions.Count).SetFirstPriority
With .DataBodyRange.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.799981688894314
End With
.DataBodyRange.FormatConditions(1).StopIfTrue = False
End With
Vielen dank an jeden der mir AntwortBeste Grüße
Mathias