Deleting a word form a worksheet

fausat

New Member
Joined
Jul 17, 2007
Messages
1
Hi

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.

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi
Assuming you are searching the word total in col A
Paste the following codes in the macro window(alt f8)
Code:
x = Cells(Rows.Count, 1).End(xlUp).Row
For a = 1 To x
If InStr(Cells(a, 1), "Total") > 0 Then
Rows(a).Delete
End If
Next a
Run the macro
It will delete all rows containing the word "Total" (Ensure uppercase and lower case letters match)
Ravi
 
Upvote 0
"the work total"

Do you mean "the word "total" " ?

If so, is there a particular column that you want to search?

Do you want to find one cell only, or might there be more than one cell?

Do you want to find cell(s) where the whole cell equals "total", or only cell(s) where "total" is part of the cell?
 
Upvote 0
ravishankar,

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
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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