Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Hi, I have another "small" problem with updating information. I'm no trying to attemp to update from "multipage two" with its "update button on the userform. This "update" button only updates data o sheet two. It updates specific items by number. If I input any ite number for whoever, it changes the item for that person. This updat button only updates current data being typed into the textboxes. would also like to update the general data on sheet 1. Here's an example of what I would like to do: If I enter 1001.01 the select "update" on the userform, the person' information is updated lets say from 1002.01. "1002.01" was th person's other item at that time. As I select "update", I would lik 1001.01 on "Sheet 1" to increase by 1 and 1002.01 to decrease by 1. Here's the coding so far: Private Sub CommandButton1_Click() IncDec TextBox4, True IncDec TextBox5, True IncDec TextBox6, True IncDec TextBox7, True IncDec TextBox8, True IncDec TextBox9, True IncDec TextBox10, True Rem IncDec TextBox11, False Rem IncDec TextBox12, False Rem IncDec TextBox13, False Rem IncDec TextBox14, False Rem IncDec TextBox15, False Rem IncDec TextBox16, False Rem IncDec TextBox17, False End Sub Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean) Dim iItem As Long With Worksheets("Sheet1") On Error Resume Next iItem = Evaluate("Match(" & textbox.Text & ",A1:H1, 0)") If iItem 0 Then If Increment Then Cells(2, iItem).Value = Cells(2, iItem).Value + 1 Else Cells(2, iItem).Value = Cells(2, iItem).Value - 1 iItem = Evaluate("Match(" & textbox.Text & ",A3:H3, 0)") If iItem 0 Then If Increment Then Cells(4, iItem).Value = Cells(4, iItem).Value + 1 Else Cells(4, iItem).Value = Cells(4, iItem).Value - 1 iItem = Evaluate("Match(" & textbox.Text & ",A5:H5, 0)") If iItem 0 Then If Increment Then Cells(6, iItem).Value = Cells(6, iItem).Value + 1 Else Cells(6, iItem).Value = Cells(6, iItem).Value - 1 End If End If End If End If End If End If End With End Sub Private Sub CommandButton2_Click() Dim lastRow As Object Set lastRow = Sheet2.Range("a65536").End(xlUp) lastRow.Offset(1, 0).Value = txtStudentID.Text lastRow.Offset(1, 1).Value = txtLastName.Text lastRow.Offset(1, 2).Value = txtFirstName.Text lastRow.Offset(1, 3).Value = TextBox4.Text lastRow.Offset(1, 4).Value = TextBox5.Text lastRow.Offset(1, 5).Value = TextBox6.Text lastRow.Offset(1, 6).Value = TextBox7.Text lastRow.Offset(1, 7).Value = TextBox8.Text lastRow.Offset(1, 8).Value = TextBox9.Text lastRow.Offset(1, 9).Value = TextBox10.Text Rem lastRow.Offset(1, 4).Value = TextBox11.Text Rem lastRow.Offset(1, 5).Value = TextBox12.Text Rem lastRow.Offset(1, 6).Value = TextBox13.Text Rem lastRow.Offset(1, 7).Value = TextBox14.Text Rem lastRow.Offset(1, 8).Value = TextBox15.Text Rem lastRow.Offset(1, 9).Value = TextBox16.Text Rem lastRow.Offset(1, 10).Value = TextBox17.Text MsgBox "One record written to Sheet2" response = MsgBox("Do you want to enter another record?", _ vbYesNo) If response = vbYes Then txtStudentID.Text = "" txtLastName.Text = "" txtFirstName.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox9.Text = "" TextBox10.Text = "" TextBox11.Text = "" TextBox12.Text = "" TextBox13.Text = "" TextBox14.Text = "" TextBox15.Text = "" TextBox16.Text = "" TextBox17.Text = "" txtStudentID.SetFocus Else Unload Me End If End Sub Private Sub CommandButton3_Click() End End Sub Private Sub CommandButton4_Click() ActiveCell.Formula = TextBox18.Text ActiveCell.Offset(0, 1).Formula = TextBox19.Text ActiveCell.Offset(0, 2).Formula = TextBox20.Text ActiveCell.Offset(0, 3).Formula = TextBox21.Text ActiveCell.Offset(0, 4).Formula = TextBox22.Text ActiveCell.Offset(0, 5).Formula = TextBox23.Text ActiveCell.Offset(0, 6).Formula = TextBox24.Text ActiveCell.Offset(0, 7).Formula = TextBox25.Text ActiveCell.Offset(0, 8).Formula = TextBox26.Text ActiveCell.Offset(0, 9).Formula = TextBox27.Text MsgBox "Record Updated" End Sub Private Sub CommandButton5_Click() Dim lastRow As Long If ActiveSheet.Name = "Sheet1" Then CommandButton5.Enabled = False Else If ActiveCell.Column < 1 Then Cells(ActiveCell.Row, 1).Select End If If ActiveCell.Row < lastRow Then ActiveCell.Offset(1, 0).Select TextBox18.Text = ActiveCell.Value TextBox19.Text = ActiveCell.Offset(0, 1).Value TextBox20.Text = ActiveCell.Offset(0, 2).Value TextBox21.Text = ActiveCell.Offset(0, 3).Value TextBox22.Text = ActiveCell.Offset(0, 4).Value TextBox23.Text = ActiveCell.Offset(0, 5).Value TextBox24.Text = ActiveCell.Offset(0, 6).Value TextBox25.Text = ActiveCell.Offset(0, 7).Value TextBox26.Text = ActiveCell.Offset(0, 8).Value TextBox27.Text = ActiveCell.Offset(0, 9).Value End If End If End Sub Private Sub CommandButton6_Click() If ActiveSheet.Name = "Sheet1" Then CommandButton6.Enabled = False Else If ActiveCell.Column < 1 Then Cells(ActiveCell.Row, 1).Select End If If ActiveCell.Row < 1 Then ActiveCell.Offset(-1, 0).Select TextBox18.Text = ActiveCell.Value TextBox19.Text = ActiveCell.Offset(0, 1).Value TextBox20.Text = ActiveCell.Offset(0, 2).Value TextBox21.Text = ActiveCell.Offset(0, 3).Value TextBox22.Text = ActiveCell.Offset(0, 4).Value TextBox23.Text = ActiveCell.Offset(0, 5).Value TextBox24.Text = ActiveCell.Offset(0, 6).Value TextBox25.Text = ActiveCell.Offset(0, 7).Value TextBox26.Text = ActiveCell.Offset(0, 8).Value TextBox27.Text = ActiveCell.Offset(0, 9).Value End If End If End Sub On Multipage1 of userform Commandbutton1 represents "Entering Data" to sheet1 Commandbutton2 represents "Entering Data" to sheet2 On Multipage2 of userform Commandbutton4 represents "Update Data" for Sheet 2 only Commandbutton5 represents "Next" for sheet2 only Commandbutton6 represents "Previous" for sheet2 only Commandbutton3 represents "Closing the form" Is there a way for Commandbutton4 to update data on sheets 1 and 2? If anybody can help, look at the data under commandbutton1 and also private sub incdec. Any and all help is appreciated! Thanks, Marty6 --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use the X button on a userform | Excel Discussion (Misc queries) | |||
UserForm Button Help | Excel Programming | |||
Dynamic update of UserForm TextBox | Excel Programming | |||
How can I update the userform? | Excel Programming | |||
UserForm Update on the Fly | Excel Programming |