AW: @Renee Addition getrennte & Ct. in Spalten
13.09.2007 19:23:00
Renee
Hi Odje,
Ich versteh nicht ganz, wie Du Dir das mit den Einheiten vorstellst.
Ich hab jetzt das Makro mal so modifiziert:
1. Es wird abgefragt, mit was für einem Faktor die 2te Spalte dividiert werden soll.
2. Die Summe übernimmt die Formatierung (z.B. wenn als Währung formatiert) aus der ersten Zelle der Selektion.
Sub prcMySum()
Dim rng1to1 As Range, rngFactorized As Range
Dim lFactor As Long
If Selection.Columns.Count 2 Then Exit Sub
While lFactor = 0
lFactor = Val(InputBox("Divisionsfaktor für die 2te Spalte:", "Faktor eingeben", 100))
Wend
Set rng1to1 = Range(Cells(Selection.Row, Selection.Column), _
Cells(Selection.Row + Selection.Rows.Count - 1, Selection.Column))
Set rngFactorized = Range(Cells(Selection.Row, Selection.Column + 1), _
Cells(Selection.Row + Selection.Rows.Count - 1, Selection.Column + 1))
Cells(Selection.Row + Selection.Rows.Count, _
Selection.Column + Selection.Columns.Count - 1) = _
WorksheetFunction.Sum(rng1to1) + WorksheetFunction.Sum(rngFactorized) / lFactor
Cells(Selection.Row, Selection.Column).Copy
Cells(Selection.Row + Selection.Rows.Count, _
Selection.Column + Selection.Columns.Count - 1).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
End Sub
Greetz Renee