Show & Hide Text Boxes Doesn’t Work Correctly

OldRookie

New Member
Joined
Nov 12, 2020
Messages
36
Office Version
  1. 2013
Platform
  1. Windows
I’m trying to show and hide a text box named “Start” with the following coding in a macro:
ActiveSheet.Shapes.Range(Array(”Start”)).Visible=true

ActiveSheet.Shapes.Range(Array(”Start”)).Visible=False

When these commands are encountered during execution they don’t work correctly, if at all. I’ve looked at previous Mr Excel threads and others on the Internet. As somewhat expected, there appears to be a variety of ways to do this. Some distinguish between a “drawing tool bar” and a “control toolbox toolbar”; recommending the later. Still others seemingly embellish their commands with Boolean names and separate macros, while the heart of it employs the coding I presented above. I’m confused, I’m sure I’m missing something. What are the simplest, separate, VBA commands to show and hide a text box?

Thank you,
OldRookie
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe this from @royUK ....see post #4
 
Upvote 0
Michael M,
I saw this posting, it’s the one I mentioned with Boolean names and separate macros. I don’t understand how putting basically the same command I was trying to use in it’s own subroutine and setting it equal to a Boolean variable which is then set to True or False elsewhere solves the problem. That seems like doing what I was trying to do except with more complication. However, based on what I saw my coding doing, perhaps it has something to do with transfer of control out of the macro that’s not seeing my commands into one that has a single purpose and does see it? I can certainly try it, but if it works I won’t really understand why. I suppose then my question really boils down to: why doesn’t my existing macro see those commands?

OldRookie
 
Upvote 0
Well, 2 points
1. YOUR code works fine for me
2. I note your (”Start”)) is using Word inverted commas not Excel....but you should get an error
 
Upvote 0
Michael M,
Thank you for your interest in my problem and trying my code. It’s good to know it works, now the trick is to find out why it’s not working in my macro.

I tried the separate subroutine with Boolean variables approach and it doesn’t work either.

In regards to my use of Word inverted commas, in my code I use quotation marks. I post on Mr Excel by retyping my code in my cell phone. Perhaps that accounts for it.

I’m not sure what to try next.

Thank you,
OldRookie
 
Upvote 0
Have you tried the same code in a new workbook / worksheet.....with a different textbox AND try naming it something neutral..."myTbox" for instance !
 
Upvote 0
I created a separate workbook with separate macros for show and hide that each contained my code. It worked. I tried the same thing in my actual workbook but it didn’t work there. I don’t understand why these commands aren’t executed when they’re encountered. I’ve also gone to the length of:
Range(“a1”).value=“before”
ActiveSheet.Shapes.Range(Array(“Start”)).Visible=True
Range(“a2”).value=“after”

I did this this to make sure the show command was being reached. It was.

Something doesn’t work the way I think it does.

OldRookie
 
Upvote 0
Did you change the TextBox name ?
It's not an ActiveX textbox is it ?
You don't have ScreenUpdating turned of in your original workbook do you ?
Do A CTRL + G and paste
Application.Screenupdating=TRUE
into the Immediates window then press Enter....then retry the codes
 
Upvote 0
Yes, I changed the name to “myGoNow”; no difference.
It’s not an Active X box. It’s an Insert>TextBox. I have other similar text boxes that are hidden in a different macro and then shown at the end of this macro that’s in question. They show fine at the end of the macro. Text boxes that show and hide at the beginning of the questionable macro don’t seem to get picked up.

OldRookie
 
Upvote 0
I'm afraid I can't think of any other options at this stage....hopefully another poster will come up with a fresh idea...:mad::mad:
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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