Changing Visibility of a Text Box

CS100

New Member
Joined
Aug 5, 2016
Messages
8
Hi all,,

I am fairly new to VBA, I have been trying to write a code that changes the visibility of a text box based on changes of selection of a dropdown list.
Basically, I want to check if the user chose a specific option from the dropdown list, if he did, I want to make the text box visible, otherwise I would like to keep it hidden.

This is my code, I keep getting an error that says "unable to get the oleobjects property of the worksheet class textbox visibility" when I run the code.

Code:
Sub DropDown2767_Change()    
    If Sheets("Effective Skin Calcs").Range("I18") = 1 Then
    ActiveSheet.OLEObjects("TextBox 3").Visible = True
    
    Else
    ActiveSheet.OLEObjects("TextBox 3").Visible = False
    
    End If
    
    
End Sub

Thank you people in advance,
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
How did you create the textbox?
 
Upvote 0
That, and the textbox name, suggests that it's a Forms textbox and those aren't part of the OLEObjects collection so instead of OLEObjects try using Shapes.
Code:
Sub DropDown2767_Change()
    If Sheets("Effective Skin Calcs").Range("I18") = 1 Then
        ActiveSheet.Shapes("TextBox 3").Visible = True
    Else
        ActiveSheet.Shapes("TextBox 3").Visible = False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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