Help with user form in Excel (combobox and linking entry to next available row in spreadsheet)

I have created a user form called Time Tracker, and been able to link the first combobox (called cboIDList) to the range called ID.

I am having difficulty with the next steps:
  • Autopopulating the combobox called cboPA_Unit, which is to be based on the value that users selects for cboIDList and references the range called PA_Unit.
  • Autopopulating the combobox called cboDesc, which is based on the value that users selects for cboIDList, and references the range called Description
  • Getting data of a completed user form to populate the next available row in a target spreadsheet

For example, if the user opens the user form and selects 2017-0001 in the dropdown for the ID combo box, then the PA Unit and Description combo boxes would both autopopulate with "Unit 1" and "Reduce Publication Files" respectively.

The txtDate field should already be autopopulated with the current date:
  • I would like users to be able to edit the date if necessary, in case they were away and need to back date a record.

Once the user completes the form by entering a value in the 'Minutes' text box, then I would like the data from the form to populate the next available row in the spreadsheet called TrackingSheet as follows:

TrackingSheet!Column A = reflects value entered in cboIDList
TrackingSheet!Column B = reflects value entered in cboPA_List
Tracking Sheet!Column C = reflects value entered in cboDesc
TrackingSheet!Column D = reflects value entered in txtDate
TrackingSheet!Column E = reflects value entered in txtMinutes

If the user form is not completely filled out, then no data should be entered into the TrackingSheet.

Description of my attached sample spreadsheet:

Dynamic named ranges:
ID = Tasks!Column A
PA_Unit = Tasks! Column B
Description = Tasks!Column C

I think I've covered it. I am new at user forms, so if you feel there are glaring issues or error handling that I should add, it would be very helpful to know.

I have attached a sample spreadsheet with my user form completed thus far, as described above.
ProdMainTimeTracker.xlsm
AndreamaryAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
The first part is easy, Though I'm not quite sure why you are using comboboxes when there aren't multiple values.

Private Sub cboIDList_Change()
Dim idx As Long

    With Me
        idx = .cboIDList.ListIndex
        
        If idx <> -1 Then
            .cboDesc.Value = Sheets("Tasks").Range("C" & idx + 2).Value
            .cboPA_Unit.Value = Sheets("Tasks").Range("B" & idx + 2).Value
        End If

    End With
    
End Sub

Open in new window


For the data part, you are already populating a textbox with the current date and the user can easily change that if they want.

As for transferring the data from the userform to the sheet 'TrackingSheet', you could use this code,
Dim NextRow As Long

    With Me
    
        If .cboIDList.Value = "" _
            Or .cboDesc.Value = "" _
            Or .cboPA_Unit.Value = "" _
            Or .txtDate = "" _
            Or txtMinutes = "" Then
            
            MsgBox "Form not completed!", vbCritical, "Incomplete"
            Exit Sub
        End If
    

        NextRow = Sheets("TrackingSheet").Range("A" & Rows.Count).End(xlUp).Row + 1
        Sheets("TrackingSheet").Range("A" & NextRow).Value = .cboIDList.Value
        Sheets("TrackingSheet").Range("B" & NextRow).Value = .cboPA_Unit.Value
        Sheets("TrackingSheet").Range("C" & NextRow).Value = .cboDesc.Value
        Sheets("TrackingSheet").Range("D" & NextRow).Value = .txtDate.Value
        Sheets("TrackingSheet").Range("E" & NextRow).Value = .txtMinutes.Value
        
    End With

Open in new window


which I've put in the Click event of the command button cmdSave I've added to the userform in the attached file.
ProdMainTimeTracker-with-Save-butto.xlsm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndreamaryAuthor Commented:
Terrific - thanks very much, Norie!

I will change the combo boxes, since they aren't necessary, as you mentioned. The one thing I realized as I tested is that I should have included the clearing of the form of data after clicking the 'Save' button as part of the criteria. I'll see if I can figure that out. :-)

Cheers,
Andrea
AndreamaryAuthor Commented:
Thanks for the quick response...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.