How about
:
Option Explicit
Sub testme02()
Dim Counter As Long
Dim i As Long
Dim delRng As Range
Counter = Application.InputBox _
("Enter the total number of rows to process", Type:=1)
If Counter < 1 Then
Exit Sub
End If
With Worksheets("sheet1")
For i = 1 To Counter
If Application.IsNumber(.Cells(i, 1).Value) = False Then
If delRng Is Nothing Then
Set delRng = .Cells(i, 1)
Else
Set delRng = Union(.Cells(i, 1), delRng)
End If
End If
Next i
End With
If delRng Is Nothing Then
'nothing to do
Else
delRng.EntireRow.Delete
End If
End Sub
mjwillyone wrote:
Dear Friends,
I am having a problem with a particular macro I am working on. The
following macro is supposed to delete all rows that do not have a
number in column A. The user enters the number of rows to process,
then lets the macro do its job. Unfortately, I end up with all of the
rows being deleted.
I have checked my data on the test page and I have two rows that
contain numbers in column A. I have verified that these are numbers
by right-clicking over these cells and choosing cell-format - both are
listed as "number".
Here is the code that I have created . . .
Counter = InputBox("Enter the total number of rows to process")
Worksheets("sheet1").Activate
Range("A1").Select
For i = 1 To Counter
If ActiveCell.NumberFormat = "Number" Then
ActiveCell.Offset(1, 0).Select
Selection.EntireRow.Delete
Counter = Counter - 1
Else
Selection.EntireRow.Delete
End If
Next i
Thank you for your help!
Mike
---
Message posted from http://www.ExcelForum.com/
--
Dave Peterson