Selectbefehl vereinfachen
15.10.2008 12:25:45
Bruehmi
habe durch eure Hilfe schon einiges hier hinbekommen. Dafür nochmal ein dickes Lob von mir!
Nun stehe ich vor folgendem Rätsel:
Ich möchte verschiedene Bereiche formatieren...
Private Sub Spalten_mit_Formeln_formatieren()
Range("E20:E" & Range("E7").Value + 20).Select
With Selection.Interior
.ColorIndex = 33
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
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
Range("H20:H" & Range("E7").Value + 20).Select
With Selection.Interior
.ColorIndex = 33
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
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
... dies sind "nur" 2 der 4 Bereiche, jedoch möchte ich den Code, ein wenig sauberer, also kürzer haben. Gibt es eine Möglichkeit, die 4 Zellbereiche in ein Select zu bringen?
In etwa so:
Range(("E20:E" & Range("E7").Value + 20), ("I20:I" & Range("E7").Value + 20).Select
Gruß Bruehmi