brett_x
brett_x

Reputation: 306

VBA Delete userform control object that is off-screen

I added an Option Button to a userform and it has disappeared off-screen. I know it is still there, and I can access it though code.

It's not the end of the world, but for completeness, I'd prefer to delete it. I just can't access it in the UI. Obviously, if I could click on it in the IDE Userform window, I could easily delete it.

My thought was that I could change its location :

Dim x As Variant

For Each x In Me.Controls
    Debug.Print x.Name
    If x.Name = "OptionButton1" Then
        Debug.Print x.Left & ", " & x.Top
        x.Left = 1
        x.Top = 1
    End If
Next x

This works, but only during runtime. It goes back to its original location as soon as the program ends. FWIW, it's current location is 240, -528.

Does anyone know another way to access the object? I've also tried

Me.Controls.Remove "OptionButton1"

which also only works during runtime.

Any thoughts?

Upvotes: 0

Views: 1849

Answers (1)

simpLE MAn
simpLE MAn

Reputation: 1622

On the "Properties" window (F4) in the top dropdown list select the OptionButton1 then change the values in the Left and Top properties.

Upvotes: 3

Related Questions