Trying to do delete all rows that have text...

ermccarthy

Board Regular
Joined
Feb 15, 2002
Messages
224
I am struggling..... This is a snippet of a larger code. Trying to delete any ROWS in which the cell in column A is Text. (think isText function on the worksheet).

VBA Code:
'Declare Variables
Dim LastRow As Long, FirstRow As Long
Dim Row As Long
 
With ActiveSheet
    'Define First and Last Rows
    FirstRow = 2
    LastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
 
    'Loop Through Rows (Bottom to Top)
    For Row = LastRow To FirstRow Step -1
        If .Range("A" & Row).Value = Application.WorksheetFunction.IsText Then
            .Range("A" & Row).EntireRow.Delete
        End If
    Next Row
End With

Any ideas??
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
May be:
VBA Code:
 If  Application.WorksheetFunction.IsText(.Range("A" & Row).Value) Then

or try another version:
VBA Code:
Sub test()
Dim lr&, fr&, cell As Range
With ActiveSheet
fr = 2
lr = .Cells(Rows.Count, 1).End(xlUp).Row
    For Each cell In .Range(.Cells(fr, 1), .Cells(lr, 1))
        If Not IsNumeric(cell) Then
            cell.Delete
        End If
    Next
    .Range(Cells(fr, 1), Cells(lr, 1)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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