none
Please help with Coding Excel User Form (Previous, Next, Delete, and Edit buttons) RRS feed

  • Question

  • Hello,

    I would really appreciate any help that can be provided with creating my user form.

    I am trying to code the Previous, Next, Edit/Update, and Delete buttons.

    My entire coding for my user form is here. I am completely new to this and could use any help you're able to provide. Thank you so much.

    ______

    Private Sub cboCanRep_Change()

    End Sub

    Private Sub cmdClose_Change()

    End Sub

    Private Sub cboFollowup_Change()

    End Sub

    Private Sub cboRegion_Change()

    End Sub

    Private Sub cboStatus1_Change()

    End Sub

    Private Sub cmdAdd_Click()
        Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("MeetingTracker")

    'find first empty row in database
    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

    'check for a First Nations
    If Trim(Me.txtFN.Value) = "" Then
      Me.txtFN.SetFocus
      MsgBox "Please enter a First Nation"
      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, 1).Value = Me.TextBox1.Value
      .Cells(iRow, 2).Value = Me.txtFN.Value
      .Cells(iRow, 3).Value = Me.txtMeetingParticipant.Value
      .Cells(iRow, 4).Value = Me.txtDate.Value
      .Cells(iRow, 5).Value = Me.cboOrgType.Value
      .Cells(iRow, 6).Value = Me.cboRegion.Value
      .Cells(iRow, 7).Value = Me.txtCanRep.Value
      .Cells(iRow, 8).Value = Me.cboIssue1.Value
      .Cells(iRow, 9).Value = Me.cboStatus1.Value
      .Cells(iRow, 10).Value = Me.txtAdditionalNotes1.Value
      .Cells(iRow, 11).Value = Me.cboIssue2.Value
      .Cells(iRow, 12).Value = Me.cboStatus2.Value
      .Cells(iRow, 13).Value = Me.txtAdditionalNotes2.Value

      .Cells(iRow, 14).Value = Me.cboIssue3.Value
      .Cells(iRow, 15).Value = Me.cboStatus3.Value
      .Cells(iRow, 16).Value = Me.txtAdditionalNotes3.Value
     
      .Cells(iRow, 17).Value = Me.cboIssue4.Value
      .Cells(iRow, 18).Value = Me.cboStatus4.Value
      .Cells(iRow, 19).Value = Me.txtAdditionalNotes4.Value
      
       .Cells(iRow, 20).Value = Me.cboFollowup.Value
       
    '  .Protect Password:="password"
    End With

    'clear the data
    Me.TextBox1.Value = ""
    Me.txtFN.Value = ""
    Me.txtMeetingParticipant.Value = ""
    Me.txtDate.Value = ""
    Me.cboOrgType.Value = ""
    Me.cboRegion.Value = ""
    Me.txtCanRep.Value = ""
    Me.cboIssue1.Value = ""
    Me.cboStatus1.Value = ""
    Me.txtAdditionalNotes1.Value = ""
    Me.cboIssue2.Value = ""
    Me.cboStatus2.Value = ""
    Me.txtAdditionalNotes2.Value = ""
    Me.cboIssue3.Value = ""
    Me.cboStatus3.Value = ""
    Me.txtAdditionalNotes3.Value = ""
    Me.cboIssue4.Value = ""
    Me.cboStatus4.Value = ""
    Me.txtAdditionalNotes4.Value = ""
    Me.cboFollowup.Value = ""

    Me.txtFN.SetFocus

    End Sub

    Private Sub cmdClear_Click()
        Unload Me
        frmMeetingTracker.Show

    End Sub

    Private Sub cmdClose_Click()
        Unload Me

    End Sub

    Private Sub ComboBox1_Change()

    End Sub

    Private Sub Control1_Click()

    End Sub

    Private Sub cmdNext_Click()

    'PLEASE HELP WITH CODING THIS NEXT BUTTON

    End Sub

    Sub update()
    txtFN.Value = Sheets("MeetingTracker").Range("A9")
    txtParticipant.Value = Sheets("MeetingTracker").Range("B9")


    End Sub

    Private Sub cmdUpdate_Click()

    'PLEASE HELP WITH CODING THIS UPDATE BUTTON

    End Sub

    Private Sub CommandButton1_Click()

    End Sub

    Private Sub cmdPrevious_Click()

    'PLEASE HELP WITH CODING THIS PREVIOUS BUTTON

    End Sub


    Private Sub Label1_Click()


    Option Explicit
     
     
    Private Sub frmMeetingTracker_Initialize()
        Dim NextNum As Long
        
       NextNum = Application.WorksheetFunction.Max(Sheet1.UsedRange.Columns(1)) + 1

        Me.Label1.Caption = NextNum + 1
       
    End Sub

    Private Sub lblAdditionalNotes1_Click()

    End Sub

    Private Sub lblAdditionalNotes2_Change()

    End Sub

    Private Sub lblAdditionalNotes3_Change()

    End Sub

    Private Sub lblAdditionalNotes4_Change()

    End Sub

    Private Sub lblDate_Click()

    End Sub

    Private Sub lblFN_Click()

    End Sub

    Private Sub lblIssue1_Click()

    End Sub

    Private Sub lblMeetingParticipant_Click()

    End Sub

    Private Sub lstRegion_Click()

    End Sub

    Private Sub txtCanRep_Click()

    End Sub

    Private Sub txtDate_Click()

    End Sub

    Private Sub ListBox1_Click()

    End Sub

    Private Sub ToggleButton1_Click()


    End Sub

    Private Sub ToggleButton2_Click()

    End Sub

    Private Sub lblMPMOW_Click()

    End Sub

    Private Sub TextBox1_Change()
    'NEXT MEETING NUMBER

    Me.TextBox1 = Application.WorksheetFunction.Max(Range("A:A")) + 1

    End Sub

    Private Sub txtAdditionalNotes1_Change()

    End Sub

    Private Sub txtAdditionalNotes2_Change()

    End Sub

    Private Sub txtAdditionalNotes3_Change()

    End Sub

    Private Sub txtAdditionalNotes4_Change()

    End Sub

    Private Sub txtDate_Change()

    End Sub

    Private Sub txtMeetingID_Change()

    End Sub

    Private Sub txtFN_Change()

    End Sub

    Private Sub UserForm_Click()
    'NEXT MEETING NUMBER

    Me.TextBox1 = Application.WorksheetFunction.Max(Range("A:A")) + 1

    End Sub

    Private Sub UserForm_Initialize()
    'NEXT MEETING NUMBER

    Me.TextBox1 = Application.WorksheetFunction.Max(Range("A:A")) + 1

    End Sub

    Thursday, August 4, 2016 5:56 AM

Answers

  • Hi Jacq_ExcelUser,

    Following is the demo code to give you the example.

    Following is my form design.

    Following is the code.

    Private Sub clos_Click()
    Unload Me
    End Sub
    
    Private Sub delete_Click()
    ActiveCell.Value = ""
    Me.TextBox1.Value = ""
    
    End Sub
    
    Private Sub edit_Click()
    ActiveCell.Value = Me.TextBox1.Value
    End Sub
    
    Private Sub first_Click()
    Me.TextBox1 = ActiveSheet.Range("A1").Value
    End Sub
    
    Private Sub last_Click()
    Me.TextBox1 = Range("A1").End(xlDown).Value
    End Sub
    
    Private Sub nex_Click()
    ActiveCell.Offset(1, 0).Select
    Me.TextBox1 = ActiveCell.Value
    
    End Sub
    
    Private Sub previous_Click()
    ActiveCell.Offset(-1, 0).Select
    Me.TextBox1 = ActiveCell.Value
    End Sub
    

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 5, 2016 2:50 AM
    Moderator

All replies

  • Have a look into this file, especially sheet Advanced:
    https://dl.dropboxusercontent.com/u/35239054/Simple_Userform.xlsm

    Andreas.

    Thursday, August 4, 2016 10:10 AM
  • Hi Jacq_ExcelUser,

    Following is the demo code to give you the example.

    Following is my form design.

    Following is the code.

    Private Sub clos_Click()
    Unload Me
    End Sub
    
    Private Sub delete_Click()
    ActiveCell.Value = ""
    Me.TextBox1.Value = ""
    
    End Sub
    
    Private Sub edit_Click()
    ActiveCell.Value = Me.TextBox1.Value
    End Sub
    
    Private Sub first_Click()
    Me.TextBox1 = ActiveSheet.Range("A1").Value
    End Sub
    
    Private Sub last_Click()
    Me.TextBox1 = Range("A1").End(xlDown).Value
    End Sub
    
    Private Sub nex_Click()
    ActiveCell.Offset(1, 0).Select
    Me.TextBox1 = ActiveCell.Value
    
    End Sub
    
    Private Sub previous_Click()
    ActiveCell.Offset(-1, 0).Select
    Me.TextBox1 = ActiveCell.Value
    End Sub
    

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 5, 2016 2:50 AM
    Moderator