Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

Elegante automatische Formatierung

Forumthread: Elegante automatische Formatierung

Elegante automatische Formatierung
10.06.2004 22:22:22
Martin
Hallo,
gibt es eine Moeglichkeit bestimmte Zellen schnell und elegant zu formatiern. Ich kann dies leider nur per Recorder und erhalte einen extrem langen Code. Gibt es eine moeglichkeit dies zu verkuerzen. (mit ein paar generellen hinweisen waere mir schon viel geholfen
vielen Dank im Voraus
Range(Cells(1, 4), Cells(1, 7)).Select
Selection.NumberFormat = "#,"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'conditional formating
Range(Cells(2, 4), Cells(numberoflines + 2, 7)).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="=$N$5", Formula2:="=3*$N$5"
Selection.FormatConditions(1).Interior.ColorIndex = 34

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="=3*$N$5", Formula2:="=4*$N$5"
Selection.FormatConditions(2).Interior.ColorIndex = 6

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, Formula1:="=4*$N$5"
Selection.FormatConditions(3).Interior.ColorIndex = 7
Columns("D:G").EntireColumn.AutoFit 'columns 4-7
Anzeige

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Elegante automatische Formatierung
10.06.2004 23:48:08
Josef
Hallo Martin!
Etwas kürzer!
With Range(Cells(1, 4), Cells(1, 7))
.NumberFormat = "#,"
.BorderAround Weight:=xlMedium
End With
'conditional formating
With Range(Cells(2, 4), Cells(numberoflines + 2, 7))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="=$N$5", Formula2:="=3*$N$5"
.FormatConditions(1).Interior.ColorIndex = 34
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="=3*$N$5", Formula2:="=4*$N$5"
.FormatConditions(2).Interior.ColorIndex = 6
.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, Formula1:="=4*$N$5"
.FormatConditions(3).Interior.ColorIndex = 7
.Columns.EntireColumn.AutoFit 'columns 4-7
End With

Gruß Sepp
Anzeige
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18