Pass Values from 1 Userform to another Userform

nzepeda

Board Regular
Joined
Nov 11, 2010
Messages
58
I am trying to create 2 Userforms that will work together to display cells from a Worksheet, based off the the information provided on the Forms.

The first Userform I have works how I want it to.

It searches the Workbook for the Names for just about every sheet and populates the ListBox with those values
Code:
Sub UserForm_Initialize()


Dim N As Long


For N = 4 To ActiveWorkbook.Sheets.Count


    TrackList.AddItem ActiveWorkbook.Sheets(N).Name
    
Next N

Where I am having trouble is passing the selected Name to the next Userform. My hope is to populate the next Userform with values from cells that are in the Sheet that was selected in the first Userform.

The following is the code I have for when the user clicks the Next button that will bring up the next Userform. This is also where I get errors.
Code:
Public sMeet As String
Public Assc As Boolean
Public Meet As Worksheet


Sub NextB_Click()


    sMeet.Value = TrackList.Value
        
    If AsscED = True Then
        Assc = True
        
    ElseIf AsscOTB = True Then
        Assc = False
        
    End If
    
    Set Meet = Worksheets(sMeet)
    Unload Me
    DateForm.Show


End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Declare the Public global variables in a Standard code module (e.g.; Module1) and not in a UserForm's code module.

Alternatively, hide the 1st userform instead of unloading it. Then reference its' objects from the 2nd UserForm code with something like...

UserForm1.TrackList.Value
 
Upvote 0
Thanks, declaring the Public global variables in a Module seem to have solved a lot of my issues.
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,264
Members
448,558
Latest member
aivin

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