ActiveX Button to Hide/Unhide Rows in Protected Worksheet

Dimaa

New Member
Joined
Apr 2, 2011
Messages
8
Hi all,

I've got a worksheet that is bilingual. I input all cells in the worksheet once, did a translation and input all that translated info into a second set of rows. The first column includes a reference, either "1" or "2", depending on whether the row uses the original or the translation. Finally, I inserted a activeX control button linked to a macro that identifies the reference in column 1, hides all the rows with a 1 and unhides all the rows with a 2 or vice versa.

I'd now like to hide the first column from the user. But when I do this, the hide/unhide function freezes. I've seen a number of solutions proposed. I prefer not to use this option since errors in the code could stop the vb while the worksheet is still unprotected:

Code:
ActiveSheet.Protect Password:="password"

[Other code here]

ActiveSheet.Unprotect Password:="password"
Code:

Internet blogs suggest that if you check the option allowing users to format rows and columns when protecting the worksheet, it should allow users to hide unhide. I think this wouldn't solve my problem since I need to prevent a column from getting unhidden but allow rows to get hidden/unhidden [which includes a bit of the protect column]. But I tried it, and even with both options checked, protecting the worksheet blocks the translation macro. This is why I've not even bothered to try programmatically using the "Allowformattingrows" property of the protection object.

I found this proposed solution:

Code:
ActiveSheet.Protect Password:="password", UserInterfaceonly:=True
Code:

I tried putting this bit of code into sub procedure [e.g., Protect()] and module of its own. I then tried calling that procedure from the translation sub procedure with something like:

Code:
Sub Translation()

Call Protect

[Other code for hiding/unhiding rows]

End Sub
Code:

That seemed to work when I run the sub procedure from the vb editor. But when I try it from the activeX control button on the worksheet, it doesn't work!

I could use people's thoughts or suggestions to solve this. Thanks.
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Well, that's a bit silly of me. I figured out the problem while tinkering with the cell formatting. I'd only paid attention to unchecking the "locked" option for cell formatting the rows being hid/unhid since I thought the "hidden" option only referred to formulas. But I discovered that if I uncheck the "hidden" option for the rows, then using the userinterfaceonly:= True does its job.

Hope someone else finds this useful. =)
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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