I want to effect all sheets...ThisWorkbook?

  • Thread starter Thread starter JSnow
  • Start date Start date
J

JSnow

What i'd like to do for this VBAProject is after a certain date, say
12/31/2008, all the data in the cells, the backgrounds, borders, basically
everything will be turned white.

I'm guessing this code would go in the ThisWorkbook object and be a simple
if..then code.

And yes, this is to prank a co-worker. Happy Holiday all!
 
How about just hidding the sheet like this. Put into the thisworkbook mode
Private Sub Workbook_Open()
If Date > "12/31/2008" Then
Worksheets("Sheet1").Visible = xlSheetHidden
End If
End Sub
 
Copy the following code to the thisworkbook module. To make this code
work, you would need to change the security feature of macro,
tools>macro>security> medium/low. If you choose medium, then the
following code will work if the user enables the macro. Different
system will have its own macro security, so the code below wont work
if accessed with a different system with security set to high.

'___________________________________________________________________________
'Copy the code below to a thisworkbook module
Private Sub Workbook_Open()
'compare date date
If DateValue(Now()) >= DateValue(DateSerial(2008, 12, 31)) Then
With ThisWorkbook
For i = 1 To .Sheets.Count
.Sheets(i).Activate
With ActiveSheet.Cells
.Font.ColorIndex = 2
.Borders.ColorIndex = 2
.Interior.ColorIndex = 2
End With
Next i
End With
End If
End Sub
'___________________________________________________________________________

' You may not use the above code with a malicious intent.

I hope this helps.

Selva V Pasupathy
For more on Excel, VBA, and other resources
Please visit: http://socko.wordpress.com
 
Thanks, Socko. I replaced the color idea w/ Mike's suggestion to just hide
everything. I used ".EntireColumn.Hidden = True" and it works beautifully.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top