Submit button to save by Name

gmazza76

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

I have been using the code below to save information to an external workbook via a submit button. I have been asked to load the info into a userform by a managers name so individuals can work within their team which i have managed to accomplish with help.

I now need to amend the VB below to save by Manager name ( which is held in column "C" ) and then carry on as per below. The VB below works on the last empty cell in column N ( "14" ) Is there anyway the code below can be amended or would it need to be re written.

Rich (BB code):
lRow = Range("C" & Rows.Count).End(xlUp).Row
    For Each cell In Range("C1:C" & lRow)
        If cell.Value = ComboBox2.Value Then

I have been using the following code above to search by TM to open the userform.

On the userform i have the submit button on the managers name is in "textbox1"

I hope you can help

Thanks
Gavin

Rich (BB code):
'Submit code
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\FYVData.xls" 'Home
                Workbooks.Open Filename:="\\W2K6082\COMMON\SHARED\Gavin Mazza\Car Park\FYVData.xls"
            
                If UserForm1.TextBox13 = "Laura Haynes" Then
                    ActiveWorkbook.Sheets("Laura Haynes").Activate
                    Unload Me
                    Set ws = Worksheets("Laura Haynes")
                    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, 15).Value = Me.ComboBox2.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("FYVData.xls").Close True
                    
                End If
            End If
        End If
    End If
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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