Delete all cells with any text

excellence

Board Regular
Joined
Oct 5, 2005
Messages
128
Office Version
  1. 365
Platform
  1. MacOS
Looking for the code that would delete the content in any cell that has text in the entire spreadsheet.
Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi,
The basic principle could be : If WorksheetFunction.IsText(ActiveCell) Then ActiveCell.ClearContents
or Cells.SpecialCells(xlCellTypeConstants, 2).ClearContents
 
Last edited:
Upvote 0
Hi exellence,

test on a copy of the original data:

VBA Code:
Sub DeleteTextinActiveSheet()
  ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants, 2).ClearContents
End Sub

Holger
 
Upvote 0
Solution
Hi Holger,
Nothing short of perfect.
Just wonder if either you could explain this part "UsedRange.SpecialCells(xlCellTypeConstants, 2)" or refer me to a link. I assume the ,2 refers to text?
Even though I spend much time trying before posting, I rather understand than copy and paste.
Thanks for your time.

By the way, I never got your RSVP via email...just noticed it when reviewing the previous post .
Thanks again
 
Upvote 0
Hi excellence,

have a look at XlSpecialCellsValue enumeration (Excel) where the elements are listed.

As far as I understand you should have gotten a note for James' answer, the next notification would only be sent if you had visited the forum in the meantime - in short one notification no matter how many posts will be made to the thread until you visit the forum again.

Holger
 
Upvote 1

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top