G
Guest
This is meant to clean up excess rows that come into a file from exported
data. If the cell in column 1 is empty or contains certain words, I need to
delete the row. It will run through the loop one time. The second time I
get a runtime 424 "Object Required" error. What do I need to do to allow
this to run through approx 300 rows?
Sub row_clean()
Dim i, t As Integer
Dim cValue As String
' ********* delete unnecessary rows ***********
With ActiveCell
last_row = Cells(Rows.Count, .Column).End(xlUp).Row
For i = 1 To last_row
cValue = Cells(i, .Column).Value
If cValue = "" Or cValue = "Report:" Or cValue = "Application:" Or
cValue = "User:" Or cValue = "JCN" Then
Rows(i).Delete
last_row = last_row - 1 'not sure if this works or if I need to
use the t variable for temp stowage like below
' this next "If" allows for two or more empty cells in sequence
If i > 1 Then
t = i
i = t - 1
End If
End If
Next i
End With
End Sub
data. If the cell in column 1 is empty or contains certain words, I need to
delete the row. It will run through the loop one time. The second time I
get a runtime 424 "Object Required" error. What do I need to do to allow
this to run through approx 300 rows?
Sub row_clean()
Dim i, t As Integer
Dim cValue As String
' ********* delete unnecessary rows ***********
With ActiveCell
last_row = Cells(Rows.Count, .Column).End(xlUp).Row
For i = 1 To last_row
cValue = Cells(i, .Column).Value
If cValue = "" Or cValue = "Report:" Or cValue = "Application:" Or
cValue = "User:" Or cValue = "JCN" Then
Rows(i).Delete
last_row = last_row - 1 'not sure if this works or if I need to
use the t variable for temp stowage like below
' this next "If" allows for two or more empty cells in sequence
If i > 1 Then
t = i
i = t - 1
End If
End If
Next i
End With
End Sub