M
marty6
Here's the code:
Private Sub CommandButton1_Click()
Dim lastRow As Object
Set lastRow = Sheet1.Range("a65536").End(xlUp)
lastRow.Offset(1, 0).Value = TextBox1.Text
lastRow.Offset(1, 1).Value = TextBox2.Text
lastRow.Offset(1, 2).Value = TextBox3.Text
MsgBox "One record written to Sheet1"
response = MsgBox("Do you want to enter another record?", _
vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub btnPrevious_click()
If ActiveCell.Column <> 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row <> 1 Then
ActiveCell.Offset(-1, 0).Select
TextBox1.Text = ActiveCell.Value
TextBox2.Text = ActiveCell.Offset(1, 1).Value
TextBox3.Text = ActiveCell.Offset(1, 2).Value
End If
End Sub
Private Sub btnNext_click()
Dim lastRow As Long
If ActiveCell.Column <> 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row <> lastRow Then
ActiveCell.Offset(1, 0).Select
TextBox1.Text = ActiveCell.Value
TextBox2.Text = ActiveCell.Offset(1, 1).Value
TextBox3.Text = ActiveCell.Offset(1, 2).Value
End If
End Sub
As one can tell, it's from Microsoft's help center. As you can see,
have the previous and next buttons added. Is there a way to add a
"Update button" so that I can update the data in those cells from thi
form?
I would like to do something like this:
Private Sub btnUpdate_click()
end sub
But I don't know the code on how to. Can somebody lead me in the righ
direction on how to write the code. I have done searches on this sit
and have not really come up with anything helpful.
Any help is appreciated
marty
Private Sub CommandButton1_Click()
Dim lastRow As Object
Set lastRow = Sheet1.Range("a65536").End(xlUp)
lastRow.Offset(1, 0).Value = TextBox1.Text
lastRow.Offset(1, 1).Value = TextBox2.Text
lastRow.Offset(1, 2).Value = TextBox3.Text
MsgBox "One record written to Sheet1"
response = MsgBox("Do you want to enter another record?", _
vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub btnPrevious_click()
If ActiveCell.Column <> 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row <> 1 Then
ActiveCell.Offset(-1, 0).Select
TextBox1.Text = ActiveCell.Value
TextBox2.Text = ActiveCell.Offset(1, 1).Value
TextBox3.Text = ActiveCell.Offset(1, 2).Value
End If
End Sub
Private Sub btnNext_click()
Dim lastRow As Long
If ActiveCell.Column <> 1 Then
Cells(ActiveCell.Row, 1).Select
End If
If ActiveCell.Row <> lastRow Then
ActiveCell.Offset(1, 0).Select
TextBox1.Text = ActiveCell.Value
TextBox2.Text = ActiveCell.Offset(1, 1).Value
TextBox3.Text = ActiveCell.Offset(1, 2).Value
End If
End Sub
As one can tell, it's from Microsoft's help center. As you can see,
have the previous and next buttons added. Is there a way to add a
"Update button" so that I can update the data in those cells from thi
form?
I would like to do something like this:
Private Sub btnUpdate_click()
end sub
But I don't know the code on how to. Can somebody lead me in the righ
direction on how to write the code. I have done searches on this sit
and have not really come up with anything helpful.
Any help is appreciated
marty