Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = Lastrow To 1 Step -1
If Cells(i, 1).Value = Sheets("Sheet2").Range("i10").Value Then
Rows(i).Delete
End If
Next
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "b").End(xlUp).Row
For i = Lastrow To 1 Step -1
If Cells(i, 2).Value = Sheets("Sheet2").Range("i10").Value Then
Rows(i).Delete
End If
Next
sheets("Sheet2").activate
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "b").End(xlUp).Row
For i = Lastrow To 1 Step -1
If Cells(i, 2).Value = Sheets("Sheet1").Range("d9").Value Then
Rows(i).Delete
End If
Next
This macro has worked but when I use it on a different sheet (And change the sheet numbers in the macro) the 6th row is highlighted as incorrect when I try to run it.: If Cells(i, 2).Value = Sheets("Sheet3").Range("d9").Value Then
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.