LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Sheet Protection, Hidden Columns, and Autofit

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofit (Columns.EntireColumn.AutoFit) does not work Michiel via OfficeKB.com Excel Discussion (Misc queries) 3 February 10th 09 05:29 PM
Protected document loses all protection(hidden columns) when manually copy-pasted [email protected] Excel Discussion (Misc queries) 1 April 4th 06 10:06 PM
protected document loses all protection(hidden columns) when manually copy-pasted [email protected] Excel Worksheet Functions 3 April 4th 06 04:02 PM
How to keep hidden columns hidden using protection Dave Excel Discussion (Misc queries) 1 March 1st 06 02:20 AM
Cell protection with hidden columns Anat Excel Discussion (Misc queries) 1 November 9th 05 02:30 AM


All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"