Delete row if the cell contains specific data

HMF009

New Member
Joined
Oct 8, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi every one,

I have workbook have more that 100 sheets, and I need to delete row has specific value in all 100 sheets, note that the specific row is NOT in same range/number
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the Board!

Can you provide a little more detail?
What do these values we are looking for look like?
Are they found in a specific range (i.e. certain column(s))?
Is an exact match within the cell it is found, or just a partial match (i.e. looking for a word that might be found in a longer sentence)?
 
Upvote 0
Welcome to the Board!

Can you provide a little more detail?
What do these values we are looking for look like?
Are they found in a specific range (i.e. certain column(s))?
Is an exact match within the cell it is found, or just a partial match (i.e. looking for a word that might be found in a longer sentence)?
Hi Joe,

to specify more, in all sheets the column A contains different codes sorted in rows, (e.g. 4092) as a number, but in each sheets this code is not in the same row. I want to make I micro to find it and delete that row from all sheet
 
Upvote 0
Try this code, which will prompt you for the specific value you want to delete:
VBA Code:
Sub MyDeleteMacro()

    Dim vl As String
    Dim ws As Worksheet
    Dim rng As Range
    
'   Prompt user for value to look for
    vl = InputBox("Please enter the value you are looking for.")
    
    Application.ScreenUpdating = False
    
'   Loop through all sheets
    For Each ws In Worksheets
        Do
'           Find value
            Set rng = ws.Range("A:A").Find(What:=vl, After:=ws.Range("A1"), LookIn:=xlFormulas, LookAt:= _
                xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
                , SearchFormat:=False)
'           Delete row when found
            If Not rng Is Nothing Then rng.EntireRow.Delete
        Loop Until rng Is Nothing
    Next ws
        
    Application.ScreenUpdating = True
    
    MsgBox "Macro complete!"
        
End Sub
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

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