VBA submit error

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Afternoon,

I hope you all can help me with an error on submitting a form.

I have data that is saved in a file where the form i have created pulls all the info from to fill the present form that is submitted when complete. The form isnt submitting the info it needs to as well as i cannot step in the code as it does what it should and just freezes. The first item needs to go in colum 14 and then populate the next 5 in that row.

I am hoping that you can all help as i am only a beigginer with VBA

Rich (BB code):
Private Sub cmdsubmit_Click()
Dim iRow As Long
Dim ws As Worksheet
    If Me.JEN.Value = "" Then
        MsgBox "Please Complete is this a justified Enquiry"
    Else
        If Me.AComm.Value = "" Then
            MsgBox "Please Leave Your Comments"
        Else
            If Me.CBoxAdd.Value = "" Then
                MsgBox "Please Enter Your Name"
            Else
                Workbooks.Open Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\Data.xls" 'Home
                'Workbooks.Open Filename:="\\W2K6082\COMMON\SHARED\Gavin Mazza\Car Park\Data.xls"
 
                If UserForm1.TextBox13 = "Ashley Longman" Then
                    ActiveWorkbook.Sheets("Ashley Longman").Activate
                    Unload Me
                    Set ws = Worksheets("Ashley Longman")
                    iRow = ws.Cells(Rows.Count, 14) _
                    .End(xlUp).Offset(1, 0).Row
    'copy the data to the database
                    ws.Cells(iRow, 14).Value = Me.JEN.Value
                    ws.Cells(iRow, 16).Value = Me.TextBox12.Value
                    ws.Cells(iRow, 17).Value = Me.AComm.Value
                    ws.Cells(iRow, 18).Value = Me.CBoxAdd.Value
    'clear the data
                    Me.JEN.Value = ""
                    Me.AComm.Value = ""
                    Me.CBoxAdd.Value = ""
                    Me.TextBox12.Value = ""
                    Me.txtdate.Enabled = True
 
                    Workbooks("Data.xls").Close True
 
                End If
            End If
        End If
    End If
 
    If Me.JEN.Value = "" Then
        MsgBox "Please Complete is this a justified Enquiry"
    Else
        If Me.AComm.Value = "" Then
            MsgBox "Please Leave Your Comments"
        Else
            If Me.CBoxAdd.Value = "" Then
                MsgBox "Please Enter Your Name"
            Else
            Workbooks.Open Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\Data.xls" 'Home
            'Workbooks.Open Filename:="\\W2K6082\COMMON\SHARED\Gavin Mazza\Car Park\Data.xls"
 
            If UserForm1.TextBox13 = "Christine Whitty" Then
ActiveWorkbook.Sheets("Christine Whitty").Activate
Unload Me
                Set ws = Worksheets("Christine Whitty")
                iRow = ws.Cells(Rows.Count, 14) _
                    .End(xlUp).Offset(1, 0).Row
'copy the data to the database
                ws.Cells(iRow, 14).Value = Me.JEN.Value
                ws.Cells(iRow, 16).Value = Me.TextBox12.Value
                ws.Cells(iRow, 17).Value = Me.AComm.Value
                ws.Cells(iRow, 18).Value = Me.CBoxAdd.Value
'clear the data
                Me.JEN.Value = ""
                Me.AComm.Value = ""
                Me.CBoxAdd.Value = ""
                Me.TextBox12.Value = ""
                Me.txtdate.Enabled = True
 
                Workbooks("Data.xls").Close True
 
            End If
        End If
    End If
End If
                If Me.JEN.Value = "" Then
                    MsgBox "Please Complete is this a justified Enquiry"
Else
                If Me.AComm.Value = "" Then
                    MsgBox "Please Leave Your Comments"
            Else
                If Me.CBoxAdd.Value = "" Then
                    MsgBox "Please Enter Your Name"
        Else
            Workbooks.Open Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\Data.xls" 'Home
            'Workbooks.Open Filename:="\\W2K6082\COMMON\SHARED\Gavin Mazza\Car Park\Data.xls"
 
            If UserForm1.TextBox13 = "Andrew Mellor" Then
            ActiveWorkbook.Sheets("Andrew Mellor").Activate
Unload Me
 
                Set ws = Worksheets("Andrew Mellor")
                iRow = ws.Cells(Rows.Count, 14) _
                    .End(xlUp).Offset(1, 0).Row
'copy the data to the database
                ws.Cells(iRow, 14).Value = Me.JEN.Value
                ws.Cells(iRow, 16).Value = Me.TextBox12.Value
                ws.Cells(iRow, 17).Value = Me.AComm.Value
                ws.Cells(iRow, 18).Value = Me.CBoxAdd.Value
'clear the data
                Me.JEN.Value = ""
                Me.AComm.Value = ""
                Me.ComboBox2.Value = ""
                Me.CBoxAdd.Value = ""
                Me.TextBox12.Value = ""
                Me.txtdate.Enabled = True
 
                Workbooks("Data.xls").Close True
 
            End If
        End If
    End If
End If
End Sub

Any help with this would be great
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top