ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting values not formulas (https://www.excelbanter.com/excel-programming/389330-deleting-values-not-formulas.html)

Lp12

Deleting values not formulas
 
Hi All,
I'm looking for a way to delete cells with values but without formulas in
it? (VBA) in office 2003.
Thanks a lot in advance

papou

Deleting values not formulas
 
Hi
For Each c In Selection.Cells
If Not c.HasFormula Then c.ClearContents
Next c

HTH
Cordially
Pascal

"Lp12" a écrit dans le message de news:
...
Hi All,
I'm looking for a way to delete cells with values but without formulas in
it? (VBA) in office 2003.
Thanks a lot in advance




Lp12

Deleting values not formulas
 
Thanks a lot papou.
Thats what I was looking for.
How could I forget .Hasformula!!!!


"papou" wrote:

Hi
For Each c In Selection.Cells
If Not c.HasFormula Then c.ClearContents
Next c

HTH
Cordially
Pascal

"Lp12" a écrit dans le message de news:
...
Hi All,
I'm looking for a way to delete cells with values but without formulas in
it? (VBA) in office 2003.
Thanks a lot in advance





Dave Peterson

Deleting values not formulas
 
Another way to get them all at once:

Select the range to fix
Edit|Goto special|Constants
click ok
hit the delete key on the keyboard.

In code:

On error resume next
Selection.Cells.SpecialCells(xlTextValues).ClearCo ntents
on error goto 0

You could specify a more exact range, too:

Activesheet.range("a1:c99").Cells.SpecialCells(xlT extValues).ClearContents

Lp12 wrote:

Hi All,
I'm looking for a way to delete cells with values but without formulas in
it? (VBA) in office 2003.
Thanks a lot in advance


--

Dave Peterson

Lp12

Deleting values not formulas
 
Thanks Dave.
This is even more elegant!!!

"Dave Peterson" wrote:

Another way to get them all at once:

Select the range to fix
Edit|Goto special|Constants
click ok
hit the delete key on the keyboard.

In code:

On error resume next
Selection.Cells.SpecialCells(xlTextValues).ClearCo ntents
on error goto 0

You could specify a more exact range, too:

Activesheet.range("a1:c99").Cells.SpecialCells(xlT extValues).ClearContents

Lp12 wrote:

Hi All,
I'm looking for a way to delete cells with values but without formulas in
it? (VBA) in office 2003.
Thanks a lot in advance


--

Dave Peterson



All times are GMT +1. The time now is 02:06 PM.

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