Delete Rows Shift Up Multiple Sheets

amoverton2

Board Regular
Joined
May 13, 2021
Messages
77
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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
 
Upvote 0
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"
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,808
Members
448,990
Latest member
rohitsomani

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