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.
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Norie

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

Watch MrExcel Video

Forum statistics

Threads
1,123,398
Messages
5,601,442
Members
414,450
Latest member
Cassy_sn

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