Listbox visible false

jeffmoseler

Well-known Member
Joined
Jul 16, 2004
Messages
540
I am trying to use code to hide a listbox. This is what I have so far, but it's not working. I know the answer is simple but I can't remember. Thanks for the help.

ActiveSheet.Shapes("ListBox1").Visible = True
ActiveSheet.RefreshAll
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You would need to use false to HIDE the listbox

Code:
ActiveSheet.Shapes("ListBox1").Visible = False
 
Upvote 0
Sorry, that was a mistake. I forgot to change the code back before I posted it here. I actually have it correct but it still isn't working. Although when I click off of Excel, say on Outlook, and then click back on Excel, the listbox will be hidden. It has something to do with refreshing, but I can't remember what it is.
 
Upvote 0
Another update is that I need to toggle the "Design Mode" off and then back on, then I can click off Excel and then back on and the listbox will be gone. I know it is somekind of refresh issue. Hmmmmm

Any help would be great.
 
Upvote 0
There isn't really anything like that in Excel.

The RefreshAll method is used to update pivot tables, web queries etc.

Have you maybe turned off screen updating elsewhere in the code?
 
Upvote 0
This worked on my test sheet:

Code:
Sheet1.Shapes("List Box 1").Visible = False

Notice the spaces between List Box and 1, it's not all run together like you have it in your code. Also, I had to qualify the sheet name before the Shapes (which you did with ActiveSheet...sorry didn't see that at first)
 
Last edited:
Upvote 0
OK, I keep learning new ways to make it work, but it is still not ideal. Worse yet, I don't understand the problem and that's why I come here... to learn:)

If I write the code like this:

Application.ScreenUpdating = False
ActiveSheet.Shapes("ListBox1").Visible = True
ActiveSheet.Shapes("Picture 54").Visible = True
Application.ScreenUpdating = True
Sheets("Waybill").Select
Sheets("Info").Select

Switching sheets after the screen updating is turned on seems to fix it. But does anyone know why I have to do this?
 
Upvote 0
Jeff

2 questions.

1 Why are you turning off screen updating?

2 Why are you using Select?

Turning off screen updating can be useful in certain circumstances but I don't see why you would want/need it here.

As for using Select, you probably know what I'm going to say - it's rarely if ever needed.:)
 
Upvote 0
I read on some posts that turning screen updating off and on can refresh the screen.

I am choosing select because, again, I need the screen to refresh. When I select another worksheet and come back again it refreshes the screen to make the ListBox1 appear or disappear.
 
Upvote 0
I think you're having other issues as you shouldn't have to move away from a sheet and then back again to get the results you're looking for.

Does the issue happen with a new (clean) workbook with just one listbox?
 
Upvote 0

Forum statistics

Threads
1,222,623
Messages
6,167,114
Members
452,096
Latest member
lordy888

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