delete rows contains TOTAL word across sheets

Mussala

Board Regular
Joined
Sep 28, 2022
Messages
61
Office Version
  1. 2019
Platform
  1. Windows
Hi
I have rows some of them contains TOTAL word in column A for just two sheets(sh, mn) . I want deleting the whole rows contain TOTAL word in column A for two sheets.
thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Filter column A for the condition "Contains ... Total"; then select the displayed rows and Delete them.
 
Upvote 0
You might record a macro:
-start from Sheet2
-start recording the macro
-select sheet1, apply filter to column A, filter for "Contains ... Total"
-select fromthe visible rows and delete them
-remove the filter
-move to sheet2 and repeat
-stop recording when job done
Examine the recorded code; it migh be wise to extend the rows selected (ready to be deleted) up to (say) line 10,000 (or a value surely above your lines)

Try...
 
Upvote 0
ok i will try it, and comeback when I need help , despite of I don't use before .
 
Upvote 0
ok i will try it, and comeback when I need help , despite of I don't use before
Recording a macro is a great feature, and returns code properly working in most of the cases.
If you post the code that you get we can review it and maybe suggest some improvements
 
Upvote 0
when I do this step
-select sheet1, apply filter to column A, filter for "Contains ... Total"
then will hide the others rows . so how do I this is step
-select fromthe visible rows and delete them
if the others rows are hidden ?!
 
Upvote 0
After the filter, only rows with Total are visible; if you select all the visible rows (except the header) and delete them then you you should get what you look far: "delete rows contains TOTAL word" (hidden rows cannot be selected and thus will not be deleted)
 
Upvote 0
here is what I got
VBA Code:
Sub Macro1()
'
' Macro1 
'

'
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$A$1969").AutoFilter Field:=1, Criteria1:= _
        "TOTAL"
    Rows("3:52").Select
    Selection.Delete Shift:=xlUp
End Sub
 
Upvote 0
So the only 2 sheets you're interested in are called "sh" and "mn"? If that's correct, try the following on a copy of your workbook.

VBA Code:
Option Explicit
Sub Mussala()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        Select Case ws.Name
            Case "sh", "mn"
            With ws.Range("A1").CurrentRegion
                .AutoFilter 1, "TOTAL"
                If ws.Cells(Rows.Count, 1).End(xlUp).Row > 1 Then
                    .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
                End If
                .AutoFilter
            End With
        End Select
    Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,157
Messages
6,123,341
Members
449,097
Latest member
thnirmitha

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