ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need macro to delete all text cells in an Excel range (https://www.excelbanter.com/excel-worksheet-functions/73912-need-macro-delete-all-text-cells-excel-range.html)

GVT

Need macro to delete all text cells in an Excel range
 
When I import a table from another program into Excel, the blank cells in the
original program look blank, but Excel imports them as text. I need help
writing a macro that will identify the cells that contain text and delete
their contents.

Gary''s Student

Need macro to delete all text cells in an Excel range
 
Enter:


Sub textclear()
' gsnu
Dim r As Range
For Each r In Selection
If r.Application.IsNumber(r.Value) Then
Else
r.Value = ""
End If
Next
End Sub

Select an area of the worksheet and run the macro.
--
Gary's Student


"GVT" wrote:

When I import a table from another program into Excel, the blank cells in the
original program look blank, but Excel imports them as text. I need help
writing a macro that will identify the cells that contain text and delete
their contents.


Ken Wright

Need macro to delete all text cells in an Excel range
 
Use Dave McRitchies Trimall macro, and it will do a lot more besides:-

http://www.mvps.org/dmcritchie/excel/join.htm#trimall

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------*------------------------------*----------------
It's easier to beg forgiveness than ask permission :-)
------------------------------*------------------------------*----------------


"GVT" wrote in message
...
When I import a table from another program into Excel, the blank cells in
the
original program look blank, but Excel imports them as text. I need help
writing a macro that will identify the cells that contain text and delete
their contents.





All times are GMT +1. The time now is 10:36 PM.

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