ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear Content except for Formulas (https://www.excelbanter.com/excel-programming/388345-clear-content-except-formulas.html)

Filo

Clear Content except for Formulas
 
Hello,
What is the code to clear the content of an entire column, except for the
cells that have formulas?

Thank you!

Norman Jones

Clear Content except for Formulas
 
Hi Flo,

Try something like:

'=============
Public Sub Tester()
Dim Rng As Range

Set rng = Columns("A:A") '<<==== CHANGE

On Error Resume Next
Rng.SpecialCells(xlCellTypeConstants).ClearContent s
On Error GoTo 0

End Sub
'<<=============


---
Regards,
Norman


"Filo" wrote in message
...
Hello,
What is the code to clear the content of an entire column, except for the
cells that have formulas?

Thank you!




rm24746[_2_]

Clear Content except for Formulas
 

Filo;7553480 Wrote:
Hello,
What is the code to clear the content of an entire column, except for

the
cells that have formulas?


Thank you!


Most of the questions such as yours can easily be answered by recording
a macro TOOLS|MACRO|RECORD NEW MACRO. When I did this on a new
worksheet and selecting the "G" column I got:

Columns("G:G").Select
Selection.ClearContents

Wayne A.


--
rm24746

Gord Dibben

Clear Content except for Formulas
 
Which clears all the cells in column G.

What happened to the cells with formulas being left behind?

Maybe not so easy<g

Next time you are recording go through the steps of selecting just those cells
without formulas before clearing contents.

F5SpecialConstants


Gord Dibben MS Excel MVP


On Mon, 30 Apr 2007 17:16:59 -0500, rm24746
wrote:


Filo;7553480 Wrote:
Hello,
What is the code to clear the content of an entire column, except for

the
cells that have formulas?


Thank you!


Most of the questions such as yours can easily be answered by recording
a macro TOOLS|MACRO|RECORD NEW MACRO. When I did this on a new
worksheet and selecting the "G" column I got:

Columns("G:G").Select
Selection.ClearContents

Wayne A.




All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com