I am new to Macros and hoping this website will support me in learning and grasping the concept of macros. I need to write a macro that will delete a row in a work sheet with with the work total.
I think you'll need to make that go backwards, from the last row working up. Otherwise, if there is Total in 2 rows in a row, it will skip the 2nd.
if you have Total in A1 and A2, only row 1 will be deleted. Because after deleting row 1, what was in row 2 is now in row 1. Then it loops and it will be looking at row 2 next.
Code:
x = Cells(Rows.Count, 1).End(xlUp).Row
For a = x To 1 Step -1
If InStr(Cells(a, 1), "Total") > 0 Then
Rows(a).Delete
End If
Next a
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.