PDA

View Full Version : [SOLVED] Macro to delete rows



MJKeenan
04-16-2017, 06:05 PM
Hello, I need a macro to delete and entire row and associated row for an id number that doesn't start with 5.

Attached is an example of what I have and what I need to create.

Thanks In Advance,
Keenan

MJKeenan
04-16-2017, 08:58 PM
Thank you for not helping me!

mancubus
04-16-2017, 11:32 PM
Thank you for not helping me!

helpers here (and on many forums) provide free help and they are not your subordinates or your employees.

if you need urgent help you should ask for paid services.
many forums (or members of the forums personally) provide this too.

MJKeenan
04-17-2017, 05:58 AM
Thanks :-)

mdmackillop
04-17-2017, 11:32 AM
Merged cells, Error cells, White text: You believe in making things difficult.



Option Compare Text


Sub Test()
Call Test1
Call Test2
End Sub


Sub Test1()
Dim PL As Worksheet
Dim Rw As Long
Set PL = Sheets("Price List")
With PL
For Rw = 175 To 4 Step -9
If Left(.Cells(Rw, 4), 1) <> 5 Then
.Cells(Rw, 4).Resize(9).EntireRow.Delete
End If
Next Rw
End With
End Sub


Sub Test2()
Dim OF As Worksheet
Dim Rw As Long
Set OF = Sheets("Order Form")
With OF
For Rw = 67 To 7 Step -1
If Not Application.IsError(.Cells(Rw, 4)) Then
If Left(.Cells(Rw, 4), 1) <> 5 And .Cells(Rw, 4) <> "" And Left(.Cells(Rw, 4), 1) <> "M" Then
.Cells(Rw, 2).MergeArea.EntireRow.Delete
End If
End If
Next Rw
End With
End Sub

MJKeenan
04-24-2017, 07:10 AM
Thanks!!!