View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Check Box Macro to hide and unhide a column

I don't see anything in the code that would cause it to fail in any version.



Daphne wrote:

I just tried the Macro at home, and it works. However, it does not work
in my office's excel. Will the edition of the Excel be a factor for not
working??

Daphne wrote:
It should be the correct worksheet as it works in other macros,

I place it in the general module, will it work in this case then??


Dave Peterson wrote:
Just a guess...

Are you unprotecting (and reprotecting) the correct worksheet?

Depending on where you placed the code (General module or behind a worksheet),
you may have trouble using Activesheet.

Sub HideColumn_Area()

Sheets("Final").Unprotect

Dim myRng As Range
Dim myCbx As CheckBox

Set myRng = Worksheets("Final").Range("D:D")
Set myCbx = ActiveSheet.CheckBoxes(Application.Caller)

myRng.EntireColumn.Hidden = CBool(myCbx.Value = xlOn)

Sheets("Final").Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True

End Sub


And remember to pass the password if you used one.


Daphne wrote:

*Sorry... I mean when i apply the macros before i add in the code for
unprotecting and protecting the code, it still works, but when i add in
the code, the error msg stops me from advancing.

Please advise..

--

Dave Peterson


--

Dave Peterson