Hi JB and thanks for the tip.
Still looking for VBA though as the user I'm setting this up for knows less then I do about Excel.
I got some help on mrexcel forum but not doing what I expected.
I wanted the formula in the col F to be copied down whenever a new line was added by the form.
The code I have does that... but it copies it all the way down col F.
I could have done that manually for so many rows.
That's why I was looking for something to just go as low as the last row of data.
This is also related to another thread here about optionbutton on a form not working, which has been fixed.
I'll try and post the sheet here... scratch that, I think the file is too big
Because the code copies the formula in col F all the way down (65k)
Here's the userform code
Code:
Private Sub Calendar1_Click()
TextBox1.Value = Calendar1.Value
End Sub
Private Sub CommandButton1_Click()
Dim lr As Long
' Determine next empty row
Nextrow = _
Application.WorksheetFunction.CountA(Range("A:A")) + 1
' Transfers the name
Cells(Nextrow, 1) = TextBox1.Text
Cells(Nextrow, 2) = TextBox2.Text
Cells(Nextrow, 3) = TextBox3.Text
Cells(Nextrow, 4) = TextBox4.Text
' Transfers Amount
If OptionButton1 Then
Cells(Nextrow, 4) = TextBox4.Value
Cells(Nextrow, 5) = ""
End If
If OptionButton2 Then
Cells(Nextrow, 5) = TextBox4.Value
Cells(Nextrow, 4) = ""
End If
' Clears form for next entry
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.SetFocus
Application.ScreenUpdating = False
lr = Cells(Rows.Count, 1).End(2).Row
Range("F3:F" & lr).Formula = "=IF(A3="""","""",IF(D3="""",E3+F2,F2-D3))"
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub
Private Sub UserForm_Click()
End Sub
Think it's something to do with the line starting with lr