Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Folks,
I have a workbook with one sheet for each month. Depending on the month there are either 4 or 5 weeks so my columns N:P can be hidden in a 4 week month. In order to protect formulas and print area, I have protected each sheet in the workbook and can autofit the contents of all sheets via a macro but everytime I try to select cols N:P and hide them it takes the entire sheet and hides my contents. Here is the code I'm working with. Private Sub Workbook_Open() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Protect Password:="###", AllowFormattingCells:=True, AllowFormattingColumns:=True ws.Columns("A:V").AutoFit Range("B1").Select Next ws Sheets("January").Select Columns("N:P").Select Selection.EntireColumn.Hidden = True Range("B1").Select This latest attempt won't even autofit before it hides my January sheet. I have tried moving the Range Select after the autofit but before the next col selection, and have even tried moving the col hide event to the worksheet itself under the active event. Nothing I try seems to work. Please help! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Autofit (Columns.EntireColumn.AutoFit) does not work | Excel Discussion (Misc queries) | |||
Protected document loses all protection(hidden columns) when manually copy-pasted | Excel Discussion (Misc queries) | |||
protected document loses all protection(hidden columns) when manually copy-pasted | Excel Worksheet Functions | |||
How to keep hidden columns hidden using protection | Excel Discussion (Misc queries) | |||
Cell protection with hidden columns | Excel Discussion (Misc queries) |