Form RowSource Property Problem

Iqbal.bhroochi

New Member
Joined
May 10, 2008
Messages
6
I have two user forms named "Userform1" and "Userform2". In Userform1, I have two Command Buttons named "cmd1" and "cmd2" and in Userform2 I have Listbox1. My problem is that When I click on cmd1 on Userform1, Userform2 displays listbox1 with correct rowsource property but when I click on cmd2, first time userform2 displays previous rowsource property then I close the Userform2 then click again on cmd2 userform2 shows correct rowsource perperty.


Where is the problem. What's wrong with my code.

Here is my code:

Private Sub cmd1_Click()
UserForm2.Show
UserForm2.ListBox1.RowSource = "Group_A"
End Sub

Private Sub cmd2_Click()
UserForm2.Show
UserForm2.ListBox1.RowSource = "Group_B"
End Sub

Private Sub UserForm_Activate()
UserForm2.ListBox1.RowSource = "Group_A"
End Sub

Private Sub UserForm_Deactivate()
UserForm2.ListBox1.RowSource = ""
End Sub

Please help me.
 

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.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
When you show the userform the activate event is triggered.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,813
Messages
5,855,782
Members
431,763
Latest member
AlexisChch

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
Top