Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Marty
Is this what you want Code ------------------- Private Sub btnUpdate_Click() ActiveCell.Formula = TextBox1.Text ActiveCell.Offset(1, 1).Formula = TextBox2.Text ActiveCell.Offset(1, 2).Formula = TextBox3.Text MsgBox "Record Updated" End Sub ------------------- a word of caution here you are looking at a particular cell(Activ cell) one diagnoally down and right from it and one horizontal to th second one in such a form as x x x if this is not what you want and you want the choices to be horizonta change your .offset(1,?) to .offset(0,?) where ? = 1 or 2 HTH Davi -- Message posted from http://www.ExcelForum.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
DSC,
Thank you for the reply! I'll try that tonight. Thank you again! marty -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to assign macro coding into customized button? | Excel Discussion (Misc queries) | |||
How do I add a tooltip to an Excel toolbar button without coding? | New Users to Excel | |||
Coding a Save button............ | Excel Discussion (Misc queries) | |||
need a button for each row to create a graph for the data | Charts and Charting in Excel | |||
Coding a button or hyperlink to insert a predfined row | Excel Programming |