Code optimieren
17.07.2008 10:14:00
edie
in den Spalten C bis J wird der Mittelwert berechnet und die letzte Zelle
anschließend formatiert.
Kann der nachfolgende Code optimiert werden? Besonders
die Formatierung der ganzen letzten Zeile.
Sub Mittelwert()
Dim intRow As Integer
intRow = Cells(Rows.Count, 1).End(xlUp).Row
If Cells(intRow, 1).Font.Bold = True Then intRow = intRow - 1
Cells(intRow + 1, 3).Formula = "=Average(C7:C" & intRow & ")"
Cells(intRow + 1, 3).Font.Bold = True
Cells(intRow + 1, 3).NumberFormat = "0.0"
Cells(intRow + 1, 4).Formula = "=Average(D7:D" & intRow & ")"
Cells(intRow + 1, 4).Font.Bold = True
Cells(intRow + 1, 4).NumberFormat = "0.0"
Cells(intRow + 1, 5).Formula = "=Average(E7:E" & intRow & ")"
Cells(intRow + 1, 5).Font.Bold = True
Cells(intRow + 1, 5).NumberFormat = "0.0"
Cells(intRow + 1, 6).Formula = "=Average(F7:F" & intRow & ")"
Cells(intRow + 1, 6).Font.Bold = True
Cells(intRow + 1, 6).NumberFormat = "0.0"
Cells(intRow + 1, 7).Formula = "=Average(G7:G" & intRow & ")"
Cells(intRow + 1, 7).Font.Bold = True
Cells(intRow + 1, 7).NumberFormat = "0.0"
Cells(intRow + 1, 8).Formula = "=Average(H7:H" & intRow & ")"
Cells(intRow + 1, 8).Font.Bold = True
Cells(intRow + 1, 8).NumberFormat = "0.0"
Cells(intRow + 1, 9).Formula = "=Average(I7:I" & intRow & ")"
Cells(intRow + 1, 9).Font.Bold = True
Cells(intRow + 1, 9).NumberFormat = "0.0"
Cells(intRow + 1, 10).Formula = "=Average(J7:J" & intRow & ")"
Cells(intRow + 1, 10).Font.Bold = True
Cells(intRow + 1, 10).NumberFormat = "0.0"
End Sub
Hat jemand eine Idee oder Vorschlag?
Vielen Dank im Voraus.
Grüße