Deleting values not formulas

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi
For Each c In Selection.Cells
If Not c.HasFormula Then c.ClearContents
Next c

HTH
Cordially
Pascal
 
Thanks a lot papou.
Thats what I was looking for.
How could I forget .Hasformula!!!!
 
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).ClearContents
on error goto 0

You could specify a more exact range, too:

Activesheet.range("a1:c99").Cells.SpecialCells(xlTextValues).ClearContents
 
Thanks Dave.
This is even more elegant!!!

Dave Peterson said:
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).ClearContents
on error goto 0

You could specify a more exact range, too:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top