Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Arlen
 
Posts: n/a
Default Worksheet clearing Macros?

Does anyone know how to write a Macro that, when activated, would clear all
the data NOT in a protected cell and leave the protected formulas alone? Or,
can this be done with regular Excel functions?

While we're at it, is it possible to use Conditional Formatting to clear
cell contents, again, leaving formulas in tact?

Thank you, everybody

Arlen
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Arlen

Sub test()
On Error Resume Next
ActiveSheet.Cells.SpecialCells(xlCellTypeConstants ).ClearContents
End Sub

Manual you can do this

F5
Special
Constants
Ok
Delete

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Arlen" wrote in message ...
Does anyone know how to write a Macro that, when activated, would clear all
the data NOT in a protected cell and leave the protected formulas alone? Or,
can this be done with regular Excel functions?

While we're at it, is it possible to use Conditional Formatting to clear
cell contents, again, leaving formulas in tact?

Thank you, everybody

Arlen



  #3   Report Post  
Gord Dibben
 
Posts: n/a
Default

Arlen

To address your second question....

No. CF cannot be used to clear cell contents.


Gord Dibben Excel MVP

On Wed, 26 Jan 2005 20:31:35 +0100, "Ron de Bruin"
wrote:

Hi Arlen

Sub test()
On Error Resume Next
ActiveSheet.Cells.SpecialCells(xlCellTypeConstant s).ClearContents
End Sub

Manual you can do this

F5
Special
Constants
Ok
Delete


  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

I read it slightly differently.

Clean up any constant cell that is unlocked (no formulas and no protected cells
will change).

Option Explicit
Sub test2()
Dim myCell As Range
With Worksheets("sheet1")
For Each myCell In .UsedRange.Cells
If myCell.Locked = True _
Or myCell.HasFormula = True Then
'do nothing
Else
myCell.ClearContents
End If
Next myCell
End With
End Sub



Arlen wrote:

Does anyone know how to write a Macro that, when activated, would clear all
the data NOT in a protected cell and leave the protected formulas alone? Or,
can this be done with regular Excel functions?

While we're at it, is it possible to use Conditional Formatting to clear
cell contents, again, leaving formulas in tact?

Thank you, everybody

Arlen


--

Dave Peterson
  #5   Report Post  
Ron de Bruin
 
Posts: n/a
Default

The OP is using this now (private mail)

Sub test()
With Sheets("sheet1")
.Unprotect "ron"
On Error Resume Next
.Range("A2:G100").Cells.SpecialCells(xlCellTypeCon stants).ClearContents
.Protect "ron"
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Dave Peterson" wrote in message ...
I read it slightly differently.

Clean up any constant cell that is unlocked (no formulas and no protected cells
will change).

Option Explicit
Sub test2()
Dim myCell As Range
With Worksheets("sheet1")
For Each myCell In .UsedRange.Cells
If myCell.Locked = True _
Or myCell.HasFormula = True Then
'do nothing
Else
myCell.ClearContents
End If
Next myCell
End With
End Sub



Arlen wrote:

Does anyone know how to write a Macro that, when activated, would clear all
the data NOT in a protected cell and leave the protected formulas alone? Or,
can this be done with regular Excel functions?

While we're at it, is it possible to use Conditional Formatting to clear
cell contents, again, leaving formulas in tact?

Thank you, everybody

Arlen


--

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
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Is is possible to run macros on a protected worksheet petunia Excel Worksheet Functions 1 January 18th 05 04:55 PM
Indirect reference from one worksheet to another Bill Sturdevant Excel Worksheet Functions 2 December 17th 04 01:23 PM
Reference Data in Moved Worksheet tommcbrny Setting up and Configuration of Excel 1 December 1st 04 06:49 PM
Worksheet name and Backward compatibility Rich Excel Discussion (Misc queries) 3 November 30th 04 06:10 PM


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