Data Entry from Userform on multiple tabs

John_McClane

New Member
Joined
Apr 30, 2013
Messages
27
Hello Everyone,

Just wondered if I could get some help with this one:

I'd like to use this Pro tip: Add a UserForm to aid data entry in Excel - TechRepublic sheet as a template for a spreadsheet I would like to make. The userform is all good, I can edit the titles of everything and it does exactly what I want.

What I'd like it to do is have another field in the userform (I can do this bit, just struggling with the code) that is a dropdown box of all the tabs in the spreadsheet and it will fill the cells on the relevant tab that you have selected.

So, the first drop box would be tab: and you could select animals 1 or 2; if you select 1 it will save the details to animals 1 tab and vice versa.

Hope I've explained it properly!

Thank you in advance for any help.

John
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi
Give following a try:

Add a ComboBox to your form and name it cboSheets

Replace following line in Private Sub cmdAdd_Click procedure:

Code:
Set ws = Worksheets("Animals")

with this line:

Code:
Set ws = ThisWorkbook.Worksheets(Me.cboSheets.Text)

Add this procedure to your forms code page:

Code:
Private Sub UserForm_Initialize()
    Dim sh As Worksheet
    For Each sh In ThisWorkbook.Worksheets
        Me.cboSheets.AddItem sh.Name
    Next sh
    Me.cboSheets.ListIndex = 0
End Sub

Dave
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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