Find and delete hidden controls on a user form?

donwiss

Board Regular
Joined
Jul 5, 2020
Messages
63
Platform
  1. Windows
I know that there are at least two controls that I can't see. Based on the default names when adding, I know I need to delete Frame32 and Textbox24. I remember when the hidden frame got created, but at the time I was unable to find it.
Ideally I just issue a command that deletes them.
I am using Excel XP.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Use this code to list the control names into the Immediate window. The code goes behind a command button. Once you know the frame and visibility in the Properties window you will see a drop down, use the drop down to select the control and then delete it from the form. Test this on a copy of the workbook in case there is other code that needs to use the control.

VBA Code:
Private Sub CommandButton1_Click()
Dim cCont As Control

    For Each cCont In Me.Controls

        Debug.Print cCont.Name & cCont.Visible

    Next cCont
End Sub
 
Upvote 0
I got the list. I found Frame32, but not Textbox24. But the list appeared to be in random order. So it didn't tell me much. Now as I am still moving things around, I had not yet set tab order. That could also help find. Sure enough. I found Textbox24, and was able to select it and then delete it. Then I found Frame32. I could not select and see it. It was hidden below what I had visible. I had to move the frame to a large area and expand it to find the hidden frame.

Now new Frames and Textboxes start with 1.

Thanks for you help. I wasn't very familiar with the drop down at the top of the Properties window.
 
Upvote 0
I found out why I didn't see the Textbox24 listed in the results in the Immediate window. I knew the number of rows is limited. So I modified your sub to not list the labels. It was still way too many for the maximum of 199 rows (in my Excel XP).

I got into the lost frame problem as the default size of a new frame is way too big. And it was bigger than the frame I was trying to insert a frame into.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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