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

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