View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David McRitchie
 
Posts: n/a
Default Delete text in cells but keep formula

Hi YanYan,
See http://www.mvps.org/dmcritchie/excel/insrtrow.htm

To clear out constants in a selection range, something like one of the following::

Selection.EntireRow.SpecialCells(xlConstants).Clea rContents

Selection.SpecialCells(xlConstants).ClearContents

You could protect some cells with constants by changing them to formulas
Range("A3:A3000").EntireRow.SpecialCells(xlConstan ts).ClearContents .

The use of SpecialCells automatically limits you to the used range.
There is a problem with with Special Cells that you might encounter in an
extreme range and one that you should be very concerned about when
deleting content. Actually the failure is more than 8192 areas within a range
Failure if more than 8192 cells selected by specialcells
see MS KB http://support.microsoft.com/?kbid=832293
and there is no undo from within a macro, so even if you see that everything
is deleted you can't undo.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"YanYan" wrote in message ...
I currently have an excel grid with headers in rows and columns. Within the
cells there is data that I dont need, but I do need the formulas in those
cells, how do I clear the data in the cells without deleting the formulas?

( I have tried GO TO - Special - Constants but this clears all of my headers
rows and additional info that I need, I only want to clear the text in the
cells that currently contain formulas)