• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 59
  • Last Modified:

Combo Dropdown, value disappearing after userform unloads.

Trying to get a usable value from a Combo dropdown list UserForm...  after selecting the item in the userform, in Local the value does show that I want to use, however when the userform closes, it wipes out the value.  How do I keep the result of the dropdown to use it?  Any ideas??

Please advise and thanks.

Public Sub UserForm_Initialize()
    With ComboBox1
        .AddItem "CategoryType##Testing-APEX##"
        .AddItem "CategoryType##Testing-SAP##"
        .AddItem "CategoryType##Testing-API##"
        .AddItem "CategoryType##Testing-Lynx##"
        .AddItem "CategoryType##Testing-Misc##"
        .AddItem "CategoryType##Functional-APEX##"
        .AddItem "CategoryType##Functional-API##"
        .AddItem "CategoryType##Functional-Excel##"
        .AddItem "CategoryType##Functional-Lynx##"
        .AddItem "CategoryType##Functional-Misc##"
        .AddItem "CategoryType##Functional-SAP##"
    End With
End Sub
Public Sub CommandButton1_Click()
    SelectedType = ComboBox1.Value
    Unload Me
End Sub

'another procedure calls the userform1,  but Ln23 fails because the value collected in the userform disappears after the CommandButton1_Click() finishes..
       UserForm1.Show
        .Body = .Body & SelectedType & Chr(10)

Open in new window

0
RWayneH
Asked:
RWayneH
  • 2
1 Solution
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
On a Standard Module like Module1, declare SelectedType as Public Variable like below...

Public SelectedType As String

Open in new window

0
 
RWayneHAuthor Commented:
Yup, that one gets me everytime...  thanks.
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now