bradyboyy88
Well-known Member
- Joined
- Feb 25, 2015
- Messages
- 562
I have used some sample code from Mike Rickson where you can add additional instances of the same userform dynamically as shown in this post:
The approach is to do the following in summary:
I am using this code to create multiple userforms from right clicking on items in my dashboard i made. The issue is I have tons of public subroutines that modify the userform interface and are found in modules outside of the userform module itself. So this is an issue as the scope of these subroutines if the new instance button is pressed it targets the original form as the form name is hard coded into the subroutines. I want to dynamically add the object to target the correct form (the one with the button being pressed). I could go back and put all of these functions in the userform and set to private but that would take quite a while. Is there a way to target this new userform because it has the same name as the original so I cannot do Userform("Name").label.caption="blah BLah BLah" . Any advice would be appreciated.
Multiple Instances Of A Single Userform - OzGrid Free Excel/VBA Help Forum
This workbook has only one userform. It will create multiple instances of itself and pass data between those instances. This is the code that shows each instance of the userform. (Code, 8 lines) The (Code, 1 line) property gives each instance its…
www.ozgrid.com
The approach is to do the following in summary:
Code:
Rem show new instace of Me
Set newInstanceOfMe = UserForms.Add(Me.Name)
newInstanceOfMe.Show vbModeless
Rem unload that UF
'Unload newInstanceOfMe
Set newInstanceOfMe = Nothing
I am using this code to create multiple userforms from right clicking on items in my dashboard i made. The issue is I have tons of public subroutines that modify the userform interface and are found in modules outside of the userform module itself. So this is an issue as the scope of these subroutines if the new instance button is pressed it targets the original form as the form name is hard coded into the subroutines. I want to dynamically add the object to target the correct form (the one with the button being pressed). I could go back and put all of these functions in the userform and set to private but that would take quite a while. Is there a way to target this new userform because it has the same name as the original so I cannot do Userform("Name").label.caption="blah BLah BLah" . Any advice would be appreciated.