Delete certain rows

  • Thread starter Thread starter CPower
  • Start date Start date
C

CPower

Hi all,

Im doin a macro, and i need to get code to delete rows in col E tha
have have certain data i.e a, c, d, h. But i only want these deleted i
the rows in col G are blank. Is the some kind of if statement that ca
be used for this?
Any help on this would be great.

Thanks in advance,
Cathal
 
Try this for row 1 -100

Sub Example2()
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 = 100
For Lrow = EndRow To StartRow Step -1
If .Cells(Lrow, "E").Value = "a" Or _
.Cells(Lrow, "E").Value = "b" Or _
.Cells(Lrow, "E").Value = "c" Then _
If .Cells(Lrow, "G").Value = "" Then .Rows(Lrow).Delete
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 

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

Back
Top