Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default clear cells on open

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default clear cells on open

Hi,

Private Sub Workbook_Open()
With Sheets("Sheet1").Range("B1")
.Font.ColorIndex = 0
.ClearContents
.Font.Bold = False
End With
End Sub

You will of course have to put them back using the before_Close event

Mike

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default clear cells on open

On Fri, 23 Jan 2009 12:18:07 -0800, mike
wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike


Try this macro:

Private Sub Workbook_Open()
Worksheets("Sheet1").Range("B1").Clear
End Sub

Hope this helps / Lars-Åke
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default clear cells on open

The following will clear the the contents of B1 when you open the workbook
and say "yes" to enable macros:

Sub auto_open()
Worksheets("Sheet1").Range("B1").ClearContents
End Sub

However, they will not see what is in B1 prior to saying yes to macros since
the sheet will not yet be displayed on the screen. Also is they save the
sheet the contents of B1 are gone forever.


"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default clear cells on open

Thanks for all you input, Mike and Lars code works but not if my sheet is
protected (even if the cell B1 is unprotected). How do I get around this?

I couldn't get Craigs suggestion to work.

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default clear cells on open

Try this

Private Sub Workbook_Open()
Sheets("Sheet1").Unprotect Password:="Mypass"
With Sheets("Sheet1").Range("B1")
.Font.ColorIndex = 0
.ClearContents
.Font.Bold = False
End With
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"mike" wrote:

Thanks for all you input, Mike and Lars code works but not if my sheet is
protected (even if the cell B1 is unprotected). How do I get around this?

I couldn't get Craigs suggestion to work.

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default clear cells on open

Worked like a charm...Thanks again.

"Mike H" wrote:

Try this

Private Sub Workbook_Open()
Sheets("Sheet1").Unprotect Password:="Mypass"
With Sheets("Sheet1").Range("B1")
.Font.ColorIndex = 0
.ClearContents
.Font.Bold = False
End With
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"mike" wrote:

Thanks for all you input, Mike and Lars code works but not if my sheet is
protected (even if the cell B1 is unprotected). How do I get around this?

I couldn't get Craigs suggestion to work.

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default clear cells on open

your welcome


"mike" wrote:

Worked like a charm...Thanks again.

"Mike H" wrote:

Try this

Private Sub Workbook_Open()
Sheets("Sheet1").Unprotect Password:="Mypass"
With Sheets("Sheet1").Range("B1")
.Font.ColorIndex = 0
.ClearContents
.Font.Bold = False
End With
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"mike" wrote:

Thanks for all you input, Mike and Lars code works but not if my sheet is
protected (even if the cell B1 is unprotected). How do I get around this?

I couldn't get Craigs suggestion to work.

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default clear cells on open

That was very strange. If cell B1 is not locked, the macro should work
even if the worksheet is protected.

Lars-Åke


On Fri, 23 Jan 2009 13:36:01 -0800, mike
wrote:

Thanks for all you input, Mike and Lars code works but not if my sheet is
protected (even if the cell B1 is unprotected). How do I get around this?

I couldn't get Craigs suggestion to work.

"mike" wrote:

Super easy question..I want cell B1 cleared on workbook open.

What I am trying to do: Macros need to be enabled for my sheet to proper,
our business excel macros are off with notification and we want to keep it
that way for most users. Most people here are excel illiterate and don't even
know what a macro is, so in cell B1 I have in bold red instructions for
enabling macros.

If the macro is enabled, I want those contents cleared, or if macros are
already enabled, for those contents to clear on open.

If what I'm asking won't achieve my desired results, please enlighten me.

Thanks,

Mike


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
Create a Clear button to clear unprotected cells Jcraig713 Excel Programming 2 November 26th 07 03:55 PM
Clear Auto Filter on Close (or open) Karin Excel Discussion (Misc queries) 3 August 23rd 07 06:16 PM
macro to create toolbar on open and clear it on close mike Excel Programming 2 December 21st 05 12:12 PM
Auto Open - Clear all filters klm[_2_] Excel Programming 3 December 14th 05 09:00 PM
How do I clear all Checkboxes on a worksheet on open wapfu Excel Programming 2 August 11th 04 09:15 PM


All times are GMT +1. The time now is 03:57 AM.

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"