Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Need macro to clear contents

I need to create a macro to clear certain fields when sheet in workbook is
opened.

Thanks for the help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need macro to clear contents

in the VBE, go to the project explorer and double click on the ThisWorkbook
entry for your workbook/project

In the resulting module, in the dropdowns at the top select Workbook form
the left and Open from the right. This places

Private Sub Workbook_Open()

End Sub

in the module. Put your code here

Private Sub Workbook_Open()
With ThisWorkbook.Worksheets("Sheet1")
.Range("B9,F1,G3:H10,M11").ClearContents
End With
End Sub


--
Regards,
Tom Ogilvy


"steve_sr2" wrote in message
...
I need to create a macro to clear certain fields when sheet in workbook is
opened.

Thanks for the help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Need macro to clear contents

Do I need to replace "ThisWorkbook.Worksheets("Sheet1")" with the names of my
workbook & sheets?


"Tom Ogilvy" wrote:

in the VBE, go to the project explorer and double click on the ThisWorkbook
entry for your workbook/project

In the resulting module, in the dropdowns at the top select Workbook form
the left and Open from the right. This places

Private Sub Workbook_Open()

End Sub

in the module. Put your code here

Private Sub Workbook_Open()
With ThisWorkbook.Worksheets("Sheet1")
.Range("B9,F1,G3:H10,M11").ClearContents
End With
End Sub


--
Regards,
Tom Ogilvy


"steve_sr2" wrote in message
...
I need to create a macro to clear certain fields when sheet in workbook is
opened.

Thanks for the help!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Need macro to clear contents

Hi Steve,

Do I need to replace "ThisWorkbook.Worksheets("Sheet1")"
with the names of my workbook & sheets?


The ThisWorkbook property returns the workbook holding the code and,
therefore, requires no change.

Replace Sheet1 with the name of the sheet of interest.


---
Regards,
Norman



"steve_sr2" wrote in message
...
Do I need to replace "ThisWorkbook.Worksheets("Sheet1")" with the names of
my
workbook & sheets?


"Tom Ogilvy" wrote:

in the VBE, go to the project explorer and double click on the
ThisWorkbook
entry for your workbook/project

In the resulting module, in the dropdowns at the top select Workbook form
the left and Open from the right. This places

Private Sub Workbook_Open()

End Sub

in the module. Put your code here

Private Sub Workbook_Open()
With ThisWorkbook.Worksheets("Sheet1")
.Range("B9,F1,G3:H10,M11").ClearContents
End With
End Sub


--
Regards,
Tom Ogilvy


"steve_sr2" wrote in message
...
I need to create a macro to clear certain fields when sheet in workbook
is
opened.

Thanks for the help!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need macro to clear contents

Thisworkbook will refer to the workbook that contains the code. This will
not need changing unless the code is in another workbook other than the one
being manipulated, in which case you would use Activeworkbook.

The sheet name should be changed to whatever your sheet is called.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"steve_sr2" wrote in message
...
Do I need to replace "ThisWorkbook.Worksheets("Sheet1")" with the names of

my
workbook & sheets?


"Tom Ogilvy" wrote:

in the VBE, go to the project explorer and double click on the

ThisWorkbook
entry for your workbook/project

In the resulting module, in the dropdowns at the top select Workbook

form
the left and Open from the right. This places

Private Sub Workbook_Open()

End Sub

in the module. Put your code here

Private Sub Workbook_Open()
With ThisWorkbook.Worksheets("Sheet1")
.Range("B9,F1,G3:H10,M11").ClearContents
End With
End Sub


--
Regards,
Tom Ogilvy


"steve_sr2" wrote in message
...
I need to create a macro to clear certain fields when sheet in

workbook is
opened.

Thanks for the help!






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
Macro to clear contents of certain cells MrAcquire Excel Discussion (Misc queries) 3 February 11th 10 05:25 PM
Macro to clear contents and put an X bevchapman Excel Discussion (Misc queries) 3 March 17th 09 07:03 PM
VBA Macro to Clear Named Cell Contents [email protected] Excel Programming 3 January 3rd 06 08:42 PM
Clear Contents Macro SJC Excel Worksheet Functions 3 October 27th 05 07:26 PM
MACRO TO CLEAR CELL CONTENTS Jay Dean Excel Programming 2 October 11th 03 02:51 PM


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

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

About Us

"It's about Microsoft Excel"