#1   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 23
Default Clear Contents

I have several sheets in one workbook I use for generating invoices. Is there
a quick way to clear them (they have different setups) leaving the formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul
  #2   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 1,533
Default Clear Contents

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul


  #3   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 23
Default Clear Contents

Thanks Per...fly in the ointment I have some merged cells and it stops at them

"Per Jessen" wrote:

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul



  #4   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 35,218
Default Clear Contents

Try changing:

cell.ClearContents
to
cell.value = ""



gibbylinks wrote:

Thanks Per...fly in the ointment I have some merged cells and it stops at them

"Per Jessen" wrote:

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul




--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 23
Default Clear Contents

Thanks Dave that worked.....but too well.

Two questions.

1) Is there a way to restrict this to the current worksheet only ?
2) Is there a way to define the range cleared ?
(I have hyperlinks and notes on the RHS that I'd like left intact)

Sorry to keep moving the "goalposts"

Paul

"Dave Peterson" wrote:

Try changing:

cell.ClearContents
to
cell.value = ""



gibbylinks wrote:

Thanks Per...fly in the ointment I have some merged cells and it stops at them

"Per Jessen" wrote:

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul



--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 35,218
Default Clear Contents

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range

set sh = activesheet
For Each cell In sh.Range("a1:B99").cells
If cell.Locked = False Then
cell.value = ""
end if
Next cell

End Sub

Change the address to what you need.


gibbylinks wrote:

Thanks Dave that worked.....but too well.

Two questions.

1) Is there a way to restrict this to the current worksheet only ?
2) Is there a way to define the range cleared ?
(I have hyperlinks and notes on the RHS that I'd like left intact)

Sorry to keep moving the "goalposts"

Paul

"Dave Peterson" wrote:

Try changing:

cell.ClearContents
to
cell.value = ""



gibbylinks wrote:

Thanks Per...fly in the ointment I have some merged cells and it stops at them

"Per Jessen" wrote:

Hi Paul

This macro clear the contents of all unlocked cells in all sheets in the
active workbook.

You can insert a button on a sheet which can call this macro.

Sub ClearUnlockedCells()
Dim sh As Worksheet
Dim cell as Range
For Each sh In ThisWorkbook.Sheets
For Each cell In sh.UsedRange
If cell.Locked = False Then cell.ClearContents
Next
Next
End Sub

Regards,
Per

"gibbylinks" skrev i meddelelsen
...
I have several sheets in one workbook I use for generating invoices. Is
there
a quick way to clear them (they have different setups) leaving the
formatting
and formulas intact ?

They are all protected with most cells locked. I am hoping to be able to
have one macro linked to a cell that will work with all the sheets.

thanks

Paul



--

Dave Peterson


--

Dave Peterson
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
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
to clear contents of a spreadsheet Jerry Excel Discussion (Misc queries) 2 August 17th 07 02:20 AM
to clear contents of a spreadsheet Jerry Excel Discussion (Misc queries) 0 August 17th 07 01:43 AM
Clear Contents Of Cells Where Value = 0 carl Excel Worksheet Functions 3 July 6th 07 06:02 PM
Clear Contents Macro SJC Excel Worksheet Functions 3 October 27th 05 07:26 PM


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