Change Textbox & Combobox to Default names

Amro El ghazawei

New Member
Joined
Feb 27, 2021
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Hi,

i work in a Project and i wasn't familiar with VBA when i started this project, so i rename the textbox & Combo boxes to with different names, but currently when i need to add new textbox or combo box , i had to make many changes manually to the code, so i am thinking i need to re change the textbox & combo box to their default names , so is there any codes to do so.

thanks.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I'm assuming they are Active X controls
VBA Code:
Sub RenameObject()

Dim m As Long, n As Long
Dim obj As Object

m = 0
n = 0
For Each obj In ActiveSheet.OLEObjects
    Select Case TypeName(obj.Object)
        Case "TextBox"
            n = n + 1
            obj.Name = "TextBox" & n
        Case "ComboBox"
            m = m + 1
            obj.Name = "ComboBox" & m
    End Select
Next obj

End Sub
 
Upvote 0
I'm assuming they are Active X controls
VBA Code:
Sub RenameObject()

Dim m As Long, n As Long
Dim obj As Object

m = 0
n = 0
For Each obj In ActiveSheet.OLEObjects
    Select Case TypeName(obj.Object)
        Case "TextBox"
            n = n + 1
            obj.Name = "TextBox" & n
        Case "ComboBox"
            m = m + 1
            obj.Name = "ComboBox" & m
    End Select
Next obj

End Sub
Hi i tried the code but i didn't make any change
 
Upvote 0
HI
i think so,
i can upload the project if you like?
 

Attachments

  • Untitled.png
    Untitled.png
    159.6 KB · Views: 12
Upvote 0
HI
i think so,
i can upload the project if you like?
This is not ActiveX. ActiveX is one created on worksheet itself, not using UserForm. I think uploading will help others helpers to come up with quick solution. Many experts out there. ;)
 
Upvote 0
I agree with Zot. Based on your post there is not enough information to work with to help you. Is this code you have inherited from someone else and are trying to modify? We really need to see the workbook not just a picture of the form.

Why do you think you need to change names to original ones? The form you showed is pretty busy with controls. Managing all those while trying to make reasonable changes is not a trivial task. Help us help you by uploading a mini-sheet with all the code but a simplified set of data.
 
Upvote 0
hi

thanks for your response,

well i initiate this project based on a simple user from example, then i upgrade it accordingly, i started the project by named text boxes & combo boxes and the command bottoms, then i might need to add more object.

please find link for the project: PROJECT REPORTING 07042021.rar

for login username: admin
password: admin

thanks
 
Upvote 0
Amro, I have downloaded your workbook and have had a first look at it. If I understand you right, this is your own project that started out simple but has grown beyond your first thoughts. The form design and programming would seem to support that impression. If this were my project I would seriously consider stepping back and redesigning the project. The forms and the worksheets are very interconnected and any wholesale changes (such as renaming form controls) will cause some serious problems. Has this project been accomplishing what it was designed to do? How much more needs to be done to finish it? Is this a personal project or one for you company? To help you I will need to have more detailed discussions with you to first understand the project and then to help you formulate a better solution.
 
Upvote 0
Changing the TextBox and ComboBox name in the Userform is one thing. Then you need to change the code to relate to those renamed TextBox and ComboBox too. :cautious:
 
Upvote 0

Forum statistics

Threads
1,214,518
Messages
6,119,996
Members
448,935
Latest member
ijat

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