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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
When you show the userform the activate event is triggered.
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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