I've created a simple checkbook register where there is a formula in column G that totals E, F & G.
I also created a form.
Problem is, after hitting submit, it enters the entry at row 101 due to the formula in rows 2-100 (I think).
Is there a way to have it select next empty row and exclude the formula in G? Columns A - F have no formula.
Thanks in advance.
Here's the Form info:
I also created a form.
Problem is, after hitting submit, it enters the entry at row 101 due to the formula in rows 2-100 (I think).
Is there a way to have it select next empty row and exclude the formula in G? Columns A - F have no formula.
Thanks in advance.
Here's the Form info:
VBA Code:
Private Sub Submit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Checkbook Register")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a part number
'If Trim(Me.txtPart.Value) = "" Then
'Me.txtPart.SetFocus
'MsgBox "Please enter a part number"
'Exit Sub
'End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="password"
.Cells(iRow, 2).Value = [Text(Now(), "MM-DD-YYYY")]
.Cells(iRow, 3).Value = Me.TextBox1.Value
.Cells(iRow, 4).Value = Me.TextBox2.Value
.Cells(iRow, 5).Value = Me.TextBox3.Value
.Cells(iRow, 6).Value = Me.TextBox4.Value
' .Protect Password:="password"
End With
Unload Me
'clear the data
'Me.TextBox1.Value = ""
'Me.TextBox2.Value = ""
'Me.TextBox3.Value = ""
'Me.TextBox4.Value = ""
'Me.TextBox1.SetFocus
End Sub