exceltextboxrenameuserform

vba excel, How to rename TextBoxes on userform


I have created 112 TextBox on userform. Please help rename these of them by macro.

-TextBox21 - TextBox43 ==> aTextBox21 - aTextBox43
-TextBox44 - TextBox66 ==> bTextBox21 - bTextBox43
-TextBox67 - TextBox89 ==> cTextBox21 - cTextBox43
-TextBox90 - TextBox112 ==> dTextBox21 - dTextBox43

Solution

  • This needs a VBProject reference set for "Microsoft Visual Basic For Applications Extensibility 5.3" and "Trust access to the Visual Basic Project" checked in the Trust Center options.

    Dim f
    
    Set f = Application.VBE.ActiveVBProject.VBComponents("UserForm1")
    
    f.Designer.Controls("TextBox1").Name = "blah"