UserForm name does not change

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I inserted UserForm and some other Form Controls such as textboxes/labels etc. I changed the name of each control for example TextBox1 to Mybox, Label1 to Mylabel etc. I also changed the name of the UserForm from UserForm1 to MyUserForm. Now, when I go to coding window, I see on the left hand side, the list of all Form Controls with the new names I name them, except UserForm, it still have the same name, which is UserForm. Why not the name I changed it to (MyUserName)



Code:
Private Sub UserForm_Initialize()


End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
That code is used within the module associated to the userform so it doesnt need its name. It just runs when you initialise the userform. Try this, it should show the name:

Code:
Private Sub UserForm_Initialize()
MsgBox Me.Name
End Sub
 
Upvote 0
Thanks for your reply. No I mean the code should be like this
Code:
Private Sub MyUserForm_initialize()
End Sub
 
Upvote 0
No. The Userform events are always Userform_eventname no matter what your form is called.
 
Upvote 0
Kind of like how all the name of all the sheet/workbook events are preceded with Sheet/Workbook rather than the name of the sheet/workbook they are for.
 
Upvote 0

Forum statistics

Threads
1,223,848
Messages
6,174,995
Members
452,599
Latest member
wolf1988

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