Hi,
I have been receiving a Run-time error 1004 "Application-defined or object-defined error". I have been reading threads for a about a week with no luck. Please help!
This is the code and the line with the error is bolded below. The purpose is to have it loop through the column and find specfic words in coulmn "F" and then delete the entire row if found. The amount of rows changes so i can't set it to end at a specific row#.
Sub test()
'
' test Macro
' test
'
' Keyboard Shortcut: Ctrl+1
'
Dim workrange As Range
Dim Firstrow As Integer
Dim Lastrow As Integer
Dim lrow As Integer
Range("F:F").Select
Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.Range("F1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
For lrow = Lastrow To Firstrow Step -1
Set workrange = Cells(lrow, 6)
If workrange.Value = "ENRL" _
Or workrange.Value = "INCO" _
Or workrange.Value = "DROP" _
Or workrange.Value = "PLAN" _
Or workrange.Value = "WTLT" _
Or workrange.Value = "DECL" _
Or workrange.Value = "CANC" _
Or workrange.Value = "INPO" _
Then workrange.EntireRow.delete
Next lrow
End Sub
Any help is greatly appricated!!
I have been receiving a Run-time error 1004 "Application-defined or object-defined error". I have been reading threads for a about a week with no luck. Please help!
This is the code and the line with the error is bolded below. The purpose is to have it loop through the column and find specfic words in coulmn "F" and then delete the entire row if found. The amount of rows changes so i can't set it to end at a specific row#.
Sub test()
'
' test Macro
' test
'
' Keyboard Shortcut: Ctrl+1
'
Dim workrange As Range
Dim Firstrow As Integer
Dim Lastrow As Integer
Dim lrow As Integer
Range("F:F").Select
Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.Range("F1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
For lrow = Lastrow To Firstrow Step -1
Set workrange = Cells(lrow, 6)
If workrange.Value = "ENRL" _
Or workrange.Value = "INCO" _
Or workrange.Value = "DROP" _
Or workrange.Value = "PLAN" _
Or workrange.Value = "WTLT" _
Or workrange.Value = "DECL" _
Or workrange.Value = "CANC" _
Or workrange.Value = "INPO" _
Then workrange.EntireRow.delete
Next lrow
End Sub
Any help is greatly appricated!!