View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chris Chris is offline
external usenet poster
 
Posts: 71
Default adding row from userfrom and copying formulas

Thanks!!! - works like a charm!

RadarEye wrote:
Hi Criss,

I cooked the procedure below.

But before you use this make usure that there is a blank line between
the figures and the SUM formulas in P-AG. The blank line MUSR be
included in the formulas.

So if the last row with figures is line 23, line 24 will be blank.
the formula for P25 looks like =SUM(P1:P24)

Now you cab use this procedure

Private Sub cmdAddRow_Click()
Dim myNewRow As Long
Dim myFormulas As Long

myNewRow = Range("A4").End(xlDown).Offset(1, 0).Row

Cells(myNewRow, 1).EntireRow.Insert shift:=xlDown

Cells(myNewRow, 1).Value = Form1.TextBox1.Text
Cells(myNewRow, 2).Value = Form1.TextBox2.Text
Cells(myNewRow, 3).Value = Form1.TextBox3.Text
Cells(myNewRow, 4).Value = Form1.TextBox4.Text
Cells(myNewRow, 5).Value = Form1.TextBox5.Text
Cells(myNewRow, 6).Value = Form1.TextBox6.Text
Cells(myNewRow, 7).Value = Form1.TextBox7.Text
Cells(myNewRow, 8).Value = Form1.TextBox8.Text
Cells(myNewRow, 9).Value = Form1.TextBox9.Text
Cells(myNewRow, 10).Value = Form1.TextBox10.Text
Cells(myNewRow, 11).Value = Form1.TextBox12.Text
Cells(myNewRow, 12).Value = Form1.TextBox12.Text
Cells(myNewRow, 13).Value = Form1.TextBox13.Text
Cells(myNewRow, 14).Value = Form1.TextBox14.Text
Cells(myNewRow, 15).Value = Form1.TextBox15.Text

For myFormulas = 16 To 33
Cells(myNewRow, myFormulas).Formula = Cells(myNewRow - 1,
myFormulas).Formula
Next

End Sub


HTH,

RadarEye