UserForm Suggestions

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a few Modules that my UserForm calls in the ComboBox, however I am wondering if there's a way I can have the UserForm to close when the code is completed. I have tried inserting
VBA Code:
UserForm.Hide
at the end of each of my Modules that the ComboBox calls and it did in fact hide the the UserForm but when I would open the UserForm back up it would keep my previous selection already there and therefor would require me to have to close out and open again to have the selections blank.
If you have any suggestions/updates or even a different route than what I am currently attempting, I am open ears!

Here is my current code for my UserForm:
VBA Code:
Private Sub UserForm_Initialize()

    ComboBox.AddItem "Insert Rows"
    ComboBox.AddItem "Priors Prep"
    ComboBox.AddItem "Submit Priors"
    ComboBox.AddItem "Pricing"
    ComboBox.AddItem "Regular CS"
    
End Sub
Private Sub ComboBox_Change()

    If ComboBox.Value = "Priors Prep" Then
        Call PriorsPrep
        
    ElseIf ComboBox.Value = "Submit Priors" Then
        Call SubmitPriors
        
    ElseIf ComboBox.Value = "Pricing" Then
        Call Pricing
            
    ElseIf ComboBox.Value = "Insert Rows" Then
        Call InsertRows
            
    ElseIf ComboBox.Value = "Regular CS" Then
        Call RegularCS
       
    End If

End Sub
1646704799133.png
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
And you could write your script like this using Case instead of If:

VBA Code:
Private Sub ComboBox1_Change()
'Modified  3/8/2022  12:12:22 AM  EDT

    Select Case ComboBox1.Value

        Case "Priors Prep": Call PriorsPrep
        Case "Submit Priors": Call SubmitPriors
        Case "Pricing": Call Pricing
        Case "Insert Rows": Call InsertRows
        Case "Regular CS": Call RegularCS
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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