Delete Row where value in column equals a value in a designated cell

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
How do I change this code from deleting the row where there is "Parent" to deleting if the value equals whats In cell B1?

Need to Start in Row 4

Code:
Sub DeleteParentRows2()
'Delete Rows that have "Parent" in column B

Dim X As Long, lastrow As Long

Sheets("Children").Activate

lastrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row

For X = lastrow To 1 Step -1
    If Cells(X, 2).Value = "Parent" Then Cells(X, 2).Delete Shift:=xlUp
Next X

ActiveSheet.Name = Range("$C$1").Value

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,225,399
Messages
6,184,752
Members
453,254
Latest member
topeb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top