Code verallgemeinern
11.09.2008 10:57:08
Brehme
ich habe hier einen Code den ich ca. 90 mal anwenden müsste. Kann mir den vielleicht jemand von euch verallgemeinern?
Code:
'Daten in Tabellenblatt
Sheets(3).Select
ActiveCell.FormulaR1C1 = "=Wochenansicht!R[4]C"
Range("A1").Select
Selection.AutoFill Destination:=Range("A1:I1"), Type:=xlFillDefault
Range("A1:I1").Select
Rows("1:1").Select
Selection.Font.Bold = True
Range("A2").Select
ActiveCell.FormulaR1C1 = "=Wochenansicht!R[5]C"
Selection.AutoFill Destination:=Range("A2:I2"), Type:=xlFillDefault
Columns("A:A").EntireColumn.AutoFit
Range("B2:G2").Select
Selection.NumberFormat = "h:mm"
Range("H2:I2").Select
Selection.NumberFormat = "[h]:mm:ss"
Range("B2:I2").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="0"
Selection.FormatConditions(1).Interior.ColorIndex = 1
'Rahmen in Tabellenblatt
Range("A1:I2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
Und zwar soll Sheets.Select (3) immer zum nächsten Tabellenblatt springen (je nachdem wieviele vorhanden sind; das variiert) und in dem Tabellenblatt Wochenansicht (Blatt aus dem Daten gezogen werden) soll immer eine Zeile nach unten gesprungen werden; angefangen in der 6. Zeile. Dabei bleibt aber die Überschrift immer gleich (also Wochenansicht!R[4]C).
Wäre echt super wenn mir da jemand weiterhelfen könnte.
Danke schonmal
Gruß
Brehme