Jonas schrieb am 21.12.2010 09:09:17:
Hallo,
und hoffentlich "hallo Severus"!
Mir wurde bei meiner letzten Frage : http://www.vba-forum.de/vba_forum/viewbeitrag.aspx?ziel=7498_vba_forum/%20VBA%20Formeln%20automatisch%20weiterf%C3%BChren von einem User (Severus) gut geholfen.
*******************************************************************
Die Spalte B füllt sich automatisch bis zu einer (un)bestimmten Zeile. In den Zellen C2-H2 ist eine Formel enthalten und soll nun, durch den unten aufgeführten Code, in den entsprechenden Spalten bis zur der Zeile übertragen werden, in der auch Spalte B endet.
For lngZeile = 3 To b
For lngSpalte = 3 To 8
Cells(lngZeile, lngSpalte).FormulaR1C1 = Cells(lngZeile - 1, lngSpalte).FormulaR1C1
Next lngSpalte
Next lngZeile
In Spalte C funktioniert es zwar, in Spalte D-H klappt es leider nicht ganz. Die letzten beiden Zeilen bleiben leer. Ich hofffe jemand kann Abhilfe schaffen.
Bevor Unklarheiten entsthehen, hier nochmal der komplette Quellcode.
Danke im Vorraus!!!
Private Sub CommandButton1_Click()
If TextBox1.Text = "" Then
MsgBox (" Bitte Grundfläche des Raumes angeben!")
Else
grundf = TextBox1.Text
Worksheets("Makro_Werte").Activate
Cells(16, 1) = grundf
End If
Worksheets("makro_werte").Activate
teins = Worksheets("makro_werte").Cells(11, 5)
tzwei = Worksheets("makro_werte").Cells(15, 5)
tdrei = Worksheets("makro_werte").Cells(17, 5)
Worksheets("output").Activate
a = 5
b = 2
Do Until teins < a
Worksheets("Output").Cells(b, 2) = a
a = a + 5
b = b + 1
Loop
For lngZeile = 3 To b
For lngSpalte = 3 To 8
Cells(lngZeile, lngSpalte).FormulaR1C1 = Cells(lngZeile - 1, lngSpalte).FormulaR1C1
Next lngSpalte
Next lngZeile
Worksheets("Output").Cells(b, 2) = teins
c = b + 1
Worksheets("Output").Cells(b + 1, 2) = tzwei
Worksheets("Output").Cells(c, 3) = Worksheets("Output").Cells(c - 1, 3)
Worksheets("Output").Cells(b + 2, 2) = tdrei
Worksheets("Output").Cells(b + 2, 3) = 0
b = b + 3
Do Until Worksheets("Output").Cells(b, 2) = ""
Worksheets("Output").Cells(b, 2) = ""
b = b + 1
Loop
End
End
End Sub
Versuch mal
Cells(lngZeile, lngSpalte).FormulaR1C1 = Cells(3, lngSpalte).FormulaR1C1
und sag Bescheid ob's damit klappt |