For...Next trouble
Posted by Cory on July 24, 2001 10:59 AM
I have a column of data that begins with text in cell A1 followed by a number in A2. This pattern continues down the column for about 500 rows: text, number, text, number...
I was trying to make a button on the sheet that goes through the column, finds the cells with numeric values and deletes their corresponding ROWS. In this case it would delete every other row. I think my cValue variable is what's hanging me up, but I can't figure out another way to make it find cells with only numeric data:
Private Sub CommandButton1_Click()
Range("A1").Activate
Dim myRow As Integer
Dim myCol As Integer
Dim Counter As Integer
Counter = 0
myCol = ActiveCell.Column
cValue = IsNumeric(ActiveCell.Value)
rBegin = 1
rEnd = 20
For myRow = rEnd To rBegin Step -1
Application.StatusBar = Counter & " rows deleted."
If Cells(myRow, myCol).Value = cValue Then
Range(Cells(myRow, myCol)).EntireRow.Delete
Counter = Counter + 1
End If
Next myRow
Application.StatusBar = False
End Sub
Any ideas would be awesome!
Thanks,
Cory