delete rows if cell in row contains "a" or "o" or empty

B

bartman1980

I want to delete the entire rows if a cell in column F contains "a" or
"o" or empty.
Then I also want to delete the rows which are in a range of row 10 to
25.

I already made something but I cannot manage to only look in the range
row 10 to 25.

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.Count, "F").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "F").Value) Then
ElseIf .Cells(Lrow, "F").Value = "a" Or .Cells(Lrow,
"F").Value = "o" Or .Cells(Lrow, "F").Value = ""
Then .Rows(Lrow).Delete
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 
J

Joel

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.DisplayPageBreaks = False
.Rows("10:25").Delete
StartRow = 1
EndRow = .Cells(.Rows.Count, "F").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1
If not IsError(.Cells(Lrow, "F").Value) Then
.Cells(Lrow, "F").Value = "a" Or _
.Cells(Lrow,"F").Value = "o" Or _
.Cells(Lrow, "F").Value = "" Then

.Rows(Lrow).Delete
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 
B

bartman1980

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.DisplayPageBreaks = False
.Rows("10:25").Delete
StartRow = 1
EndRow = .Cells(.Rows.Count, "F").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1
If not IsError(.Cells(Lrow, "F").Value) Then
.Cells(Lrow, "F").Value = "a" Or _
.Cells(Lrow,"F").Value = "o" Or _
.Cells(Lrow, "F").Value = "" Then

.Rows(Lrow).Delete
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub







- Tekst uit oorspronkelijk bericht weergeven -

I ment to delete only the rows at rows 10 to 25 IF the letters a or o
or nothing are in column F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top