VBA - UserForm Multiple Sheets/Table submit button code

tedholly

New Member
Joined
Feb 19, 2021
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I am working on creating a user form that takes the data entered, and submits it on a table on a specified sheet. On the user form, how do I have the data submit to different tables on different sheets? I want to be able to click submit on the user form and specify which sheet that I want the data added to, through a searchable box (since there is over 100 projects/sheets. The data would then be added to the table on the corresponding sheet. The tables are identical and the name is the worksheet name (because the worksheet name is the project name) On the user form, I want to enter the data, and when I press submit have a searchable menu where he can specify which sheet (Which project name), we want to add the data too (which is a table on the sheet) How do I do this?

1618417675158.png

1618417899405.png
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Add a combobox to the userform and have it list all the project/sheet names.

The user would select the project/sheet they want the data to go to from that.

You could use code like this to populate the combobox when the userform opens, it could be adjusted to not list specific worksheets or to only list worksheets with names that follow a pattern
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim arrProjects() As Variant
Dim cnt As Long

    ReDim arrProjects(1 To ThisWorkbook.Sheets.Count)

    For Each ws In ThisWorkbook.Sheets
        cnt = cnt + 1
        arrProjects(cnt) = ws.Name
    Next ws

    Me.cboProjects.List = arrProjects

End Sub

In the code of the Submit button the first thing you would do would be to check the user has actually picked a project.

Code:
 
Upvote 0
My apologies as I am very new to VBA. The first code goes under the combo box for the project name?

What would the code be for the submit button?
 
Upvote 0
Sorry, not quite sure what happened with the 2nd piece of code - I'll try to fix it and post back later.
 
Upvote 0

Forum statistics

Threads
1,215,227
Messages
6,123,743
Members
449,116
Latest member
alexlomt

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