Deleting Rows With Only Text

jlkirk

Active Member
Joined
May 6, 2002
Messages
328
Office Version
  1. 365
The cells in Column A, Rows 1-5000 contain (i) only numbers, (ii) only text, or (iii) both numbers and text. The text-only cells number over 250. What I would like is a macro that would delete all rows where only text appears in the cells in column A, leaving only rows with (i) numbers only, and (ii) numbers and text, in column A.
Thanks in advance.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Actually, the "numbers only" cells are treated by Excel as text. But I still want them to remain as numbers
 
Upvote 0
Give this macro a try...
Code:
Sub DeleterRowsWithTextInColumnA()
  Dim X As Long, UnusedColumn As Long, LastRow As Long
  Const StartRow As Long = 2
  UnusedColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, _
                 SearchDirection:=xlPrevious, LookIn:=xlFormulas).Column + 1
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  For X = StartRow To LastRow
    If Not Cells(X, "A").Value Like "*#*" Then Cells(X, UnusedColumn).Value = "X"
  Next
  Columns(UnusedColumn).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
End Sub

I assumed your data started in Row 2 (with Row 1 containing headers)... if that is not correct, then change the StartRow constant (the Const statement) to the row number where your data actually starts at.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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