VBA: Hiding/unhiding checkboxes - error

Bats Belfry

New Member
Joined
Jun 12, 2011
Messages
2
Experts,

I have spent the greater part of my weekend working on a spreadsheet for my employer; I'm almost done save for an annoying little issue simplified in this file. Unfortunately I am not VBA savvy enough to identify the error.

What I try to achieve is to hide and unhide some checkboxes. Everything is fine first time I run the macro - both the 'hide' and 'unhide' part. But if I hide the checkboxes, save the file, close Excel, reopen the file, and attemps to unhide, the checkboxes will be squashed and useless. The mentioned file should display these characteristics.

What have I done wrong? Something with the formatting?

I appreciate any advice you might have. Thanks

Bats
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the board.

I see your problem and can't give you an answer to why exactly it is squashing your check boxes only after a save, close and reopen. Though, I can suggest a work around that should work.

Even though the provided file was just an example I assume the check boxes are grouped on the actual sheet as well. Select the group and open its properties and look for the Object Position select Move but don't size with cells. Now depending on if want to hide the rows in addition to hiding the check boxes' group you may need to alter the following code.

Code:
Sub hide()
    ActiveSheet.Shapes.Range(Array("Group 1")).Visible = msoFalse
    '// Omit below if you don't need to hide the rows
    Rows("6:15").EntireRow.Hidden = True
End Sub

Sub unhide()
    ActiveSheet.Shapes.Range(Array("Group 1")).Visible = msoTrue
    '// Omit below if you don't need to hide the rows
    Rows("6:15").EntireRow.Hidden = False
End Sub

"Group 1" is the name of the group in the example file but you will have to open the selection pane to verify.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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