Detecting active userform

VanMn

New Member
Joined
Jan 1, 2004
Messages
37
I have a spreadsheet with interacting userforms and I have hit a snag when calling on a second userform while a previous is still active. There are times I want the value of a combobox in the first to be transferred to the second so I used this code for userform2.

Private Sub UserForm_Activate()
UserForm2.ComboBox1.SetFocus
If UserForm1.Visible = True Then
UserForm2.ComboBox1.Value = UserForm1.ComboBox2.Value
Else: Exit Sub
End If
End Sub

This seems to work with one large exception. When userform1 is not active, the “if” statement triggers the userform1 to activate, which is not what I want at all. Should I be using something other then a visible argument?

Ideas would be appreciated
Thanks
VanMN
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
VanMN,

For me it doesn't (running Office XP)
UserForm1 is staying at the background when Userform2 is called from Userform1.
When Userform2 is called with another sub UserForm1 stays unactivated.

or is there something missing in my comprehension ?

check by using a "breakpoint" in your code to see if its really If UserForm1.Visible = True Then which is activating Userform1
(breakpoint: click in this codeline and hit F9 then run)

best regards,
Erik
(I answered because nobody did: anyway this gives you a "bumb" :wink: )
 
Upvote 0

Forum statistics

Threads
1,202,909
Messages
6,052,495
Members
444,587
Latest member
ezza59

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