Macro to Delete Duplicate Headers from Row 4 Onwards

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,563
Office Version
  1. 2021
Platform
  1. Windows
I have written code to delete rows from row 4 onwards where "Vin" appears in Col B

When running the macro, none on the rows from Row 4 in delete where "Vin" appears in B4 onards


Code:
 Sub Remove_Duplicate_Headers()

 With Sheets("Stock Detail")
.Range("B4").AutoFilter 1, "Vin*"
.AutoFilter.Range.Offset(1).EntireRow.Delete
.AutoFilterMode = False

End With

End Sub


It would be appreciated if someone could amend my code
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hello!
Could you post example of your data on a sheet?
 
Upvote 0
@howard, your question isn't 100% clear but if you are saying that you want items in row 4 deleted then just to point out that Autofilter requiress a header row, if you need it to delete the items in row 4 then you need to apply the filter to B3.
 
Upvote 0
Hi Guys

Please see link below

What I am trying to do is to remove all rows from row 4 onwards where 'Vin" appears in Col B in the example row 11,16 & 20

 
Upvote 0
I don't know why you want it from row 4 (I have done the code below for row 4) when the data starts in row 2 and your sheet name is different in the file (amend if needed).
The reason it wasn't working was the blank rows that you had

VBA Code:
Sub Remove_Duplicate_Headers()

    With Sheets("Sheet1")
        .Range("B3:B" & .Range("B" & Rows.Count).End(xlUp).Row).AutoFilter 1, "Vin*"
        .AutoFilter.Range.Offset(1).EntireRow.Delete
        .AutoFilterMode = False
    End With

End Sub
 
Last edited:
Upvote 0
Thanks for the help & your input. Have been through your code and It makes perfect sense
 
Upvote 0

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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