userform .name property

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
IF I add a user form, I can change default form name from UserForm1 to whatever I'd like; lets say I rename it to u1
Lets say I create a userform click event that states: MsgBox Me.Name
That will work and msgbox will return 'u1'
My problem is with a function that I created, where I have declared: Private Function Do_something(byval someform as msforms.userform)
I can address almost all properties for someform userform object with exception .name? Why is that? I would like to know which userform I'm dealing with when it runs through my function but am unable to get the .name property from someform object.
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You could use something like
Code:
Function Fluff(Uf As MSForms.UserForm)
   Fluff = Uf.Controls(1).Parent.Name
End Function
Sub chk()
   MsgBox Fluff(userform1)
End Sub
 
Upvote 0
Or declare it as an object:
Code:
Private Function Do_something(ByVal someform As Object)

As an aside, you can check the userform object against its type, you shouldn't really be using the name as a string. As an example:
Code:
Sub test()

    Dim uf As uf1
    Set uf = New uf1
    
    Do_something uf
End Sub


Private Function Do_something(ByVal someform As UserForm)
    Msgbox TypeOf someform Is uf1
End Function
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

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