Duplicate heading rows problem

Imrkhp

New Member
Joined
Oct 22, 2017
Messages
3
I have merged 50 excel files in one file. Problem is that, there are 50 heading rows in my new created file. How I delete all heading rows except first.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Assuming the headers can be based on the first 6 columns in row1.
Try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG22Oct41
[COLOR=navy]Dim[/COLOR] Lst [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Txt [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] n [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
Lst = Range("A" & Rows.Count).End(xlUp).Row
Txt = Join(Application.Transpose(Application.Transpose(Range("A1").Resize(, 6))), ",")
[COLOR=navy]For[/COLOR] n = Lst To 2 [COLOR=navy]Step[/COLOR] -1
   [COLOR=navy]With[/COLOR] Range("A" & n)
        [COLOR=navy]If[/COLOR] Txt = Join(Application.Transpose(Application.Transpose(.Resize(, 6))), ",") [COLOR=navy]Then[/COLOR]
                 .EntireRow.Delete
        [COLOR=navy]End[/COLOR] If
   [COLOR=navy]End[/COLOR] With
[COLOR=navy]Next[/COLOR] n
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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