Delete Rows Shift Up Multiple Sheets

amoverton2

Board Regular
Joined
May 13, 2021
Messages
63
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the same data or keywords on multiple sheets. I want to put a keyword into a textbox on a userform, then click a command button, where it deletes the entire row if that keyword is found on multiple sheets then shift everything below it up at the same time.

I found this video on youtube but it works for one sheet, how can I make it so I can delete rows across all of my sheets or a selection of sheets:

I can do the above but I have 5 or 6 sheets and that's 5 or 6 buttons (one per sheet I want to delete). I want to combine it into one button (To rule them all!!!)

Thanks!
Adam
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
18,233
Office Version
  1. 2013
Platform
  1. Windows
Try this:
VBA Code:
Private Sub CommandButton1_Click()
'Modified  9/29/2021  1:24:47 AM  EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Dim c As Long
Dim i As Long
Dim s As Variant
c = 2 ' Column Number Modify this to your need
s = cmbDELNAM.Value

For i = 1 To Sheets.Count

    Select Case Sheets(i).Name ' Modify the below sheet names
    
    Case "E_ProspectiveGain_Add", "E_AdminInfoGain_Add", "E_LastContact_Add", "E_TravelInfo_Add", "E_FamilyInfo_Add", "E_MiscNotes_Add"
        
        
        Lastrow = Sheets(i).Cells(Rows.Count, c).End(xlUp).Row

With Sheets(i).Cells(1, c).Resize(Lastrow)
    .AutoFilter 1, s
    Counter = .Columns(c).SpecialCells(xlCellTypeVisible).Count
    
    If Counter > 1 Then 'Modified
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    
    Else
        MsgBox "The Value " & s & vbNewLine & "On sheet Named  " & Sheets(i).Name & vbNewLine & "Was not found"
    End If
    .AutoFilter
End With
End Select
Next
Application.ScreenUpdating = True
End Sub
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
18,233
Office Version
  1. 2013
Platform
  1. Windows
This script runs when you click a button named:
CommandButton1
You must select a value in the Combobox first.
Your selecting the value your looking for in column B of each sheet
The script only runs on these sheets:
"E_ProspectiveGain_Add", "E_AdminInfoGain_Add", "E_LastContact_Add", "E_TravelInfo_Add", "E_FamilyInfo_Add", "E_MiscNotes_Add"
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
18,233
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

So did this work for you. Have not heard back from you
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,240
Messages
5,768,990
Members
425,508
Latest member
jeremyb1996

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
Top