Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 122
Default Re-post: Code to make sheet very hidden based on date

I need some code to hide a sheet if a date has past. Date is in Cell
a1 of sheet 1 and sheet 2 needs to be very hidden. I would rather
not use regular conditional formatting since formats can be copied and
pasted thus changing cell formats.

I would like to make the worksheet very hidden if possible.

If you can provide the code, please tell me where to paste it. I am
new to VB for Excel

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Re-post: Code to make sheet very hidden based on date

This will do it. You might investigate using protection on the sheets as
well. Nice thing here is the sheets just look like nothing is there. Bad
thing is that you get a good pause on opening if in fact a sheet is being
hidden. Once hidden, though, no extra pauses.

Also note that you must sign this file on the specific machine and set
security to allow execution of signed macro files, or else a person can just
not run macro and still see earlier date. Or, you can run the macro every
night before anyone has chance to see.

Note that this is not really that secure. Better would be to have
lower-trust users edit on a signle-sheet workbook then you come in at night,
open both that workbook and your workbook with the master collection of
dates, tile horizontally within the Excel window, and just slide their edited
sheet into your protected master workbook with all dates. If you are system
admin you can even have them as limited user accounts (in Windows OS) and get
real protection this way...just go into "Low Trust User's Documents" (with
real name, of course) and into your own My Documents, open the two in Excel,
and slide across the sheet for latest day. Then, have a blank version as
Blank tab in your master workbook, and slide the blank back across while
pressing CTRL to make a copy instead of just moving.

But, here is code to do as you requested.

Private Sub Workbook_Open()
Dim EachSheet As Worksheet
Dim EachColumn As Range
Dim ScreenStatus As Boolean
Dim WindowStatus As Long

WindowStatus = Application.WindowState
Application.WindowState = xlMinimized 'Hide contents while hiding sheet
contents
ScreenStatus = Application.ScreenUpdating
Application.ScreenUpdating = False 'Don't try to update screen
(redundant if in fact using WindowState xlMinimized)
For Each EachSheet In Worksheets
If Int(CDate(EachSheet.Range("A1").Value)) <= Int(Now) And
EachSheet.Range("A1").EntireColumn.ColumnWidth < 0 Then
For Each EachColumn In EachSheet.Columns
EachColumn.ColumnWidth = 0
Next
End If
Next
Application.ScreenUpdating = ScreenStatus
Application.WindowState = WindowStatus

End Sub


"wx4usa" wrote:

I need some code to hide a sheet if a date has past. Date is in Cell
a1 of sheet 1 and sheet 2 needs to be very hidden. I would rather
not use regular conditional formatting since formats can be copied and
pasted thus changing cell formats.

I would like to make the worksheet very hidden if possible.

If you can provide the code, please tell me where to paste it. I am
new to VB for Excel

Thanks

Reply
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
Formula or Code to keep Hidden Rows Hidden Carol Excel Worksheet Functions 6 May 1st 07 11:45 PM
How to make hidden sheet invisible LLee2 New Users to Excel 9 April 8th 07 06:58 AM
Does anyone know how I can seperate a post code in my data sheet? gsmcellular Excel Discussion (Misc queries) 3 July 8th 06 01:32 PM
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? Daniel Excel Worksheet Functions 2 June 28th 05 05:34 AM
how do I make a new spread sheet pop up, based on an entry in a c. jpryce Excel Discussion (Misc queries) 1 April 15th 05 07:57 PM


All times are GMT +1. The time now is 06:20 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"