Hide / Show Group of Shapes / Textboxes based on Cell Value or Drop Down List

JonReyno

Board Regular
Joined
Jun 8, 2009
Messages
130
Office Version
  1. 365
Platform
  1. Windows
Morning All,

I have a workbook that I am working on and I have a load of shapes, textboxes and labels grouped together (Group 102) on a sheet (Income) and I would like to hide the group if a cell value or drop down is 1 or show it if it's 2. I have tried many various things that I have found via googling (other search engines are available) but none of them appear to work. The textboxes are from ActiveX Controls and the shapes and labels are created using shapes or text boxes.

An example of what I've been trying to do is below, but it doesn't work :(

VBA Code:
Sub HideUnhideShape()
If Worksheets("Income").Range("AB1") > 1 Then
Worksheets("Income").Shapes.Range(Array("Group 102")).Visible = False
Else
Worksheets("Income").Shapes.Range(Array("Group 102")).Visible = True
End If
End Sub

Any suggestions would be appreciated and I'm happy for the code I've given to be scraped if it's no good.

If the self-isolation doesn't drive me crazy it will be the VBA!

Thanks all
Jon
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Your code as written works for me.

What errors/issues are you having.
 
Upvote 0
Your code as written works for me.

What errors/issues are you having.
That's strange. It's not doing anything for me. There is no error, it passes alright, but the group doesn't hide or unhide regardless of what I put in Cell AB1
 
Upvote 0
How are you running that code?
 
Upvote 0
How are you running that code?
I have tried putting in the workbook module and also the page module, but neither work. I expected that when I put a 1 in AB1 then it would make the group disappear. I think perhaps I need to put it down as a change function which could be where I'm going wrong? Sorry, I'm teaching myself VBA and it's not my area of expertise, lol
 
Upvote 0
I have tried putting in the workbook module and also the page module, but neither work. I expected that when I put a 1 in AB1 then it would make the group disappear. I think perhaps I need to put it down as a change function which could be where I'm going wrong? Sorry, I'm teaching myself VBA and it's not my area of expertise, lol

I appear to have answered my own question!! The code does work!!! I just needed to amend it so it is looking at a change value. I think I had been looking at it so long that I had gone blind to what was missing.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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