Merge sheets based on keyword in tab

Mountaineer00

New Member
Joined
Feb 10, 2011
Messages
12
I have a workbook with about 20 tabs and a third of those tabs have a similar word in tab name, i.e. SALES_Detail. Detail is the same across tabs. Each sheet has identical column headings starting in row 2. What I would like to do is using the Detail in the tab name, merge all sheets into one with the column headings starting in row 2.

I've searched and searched but can't seem to find what I need. Any help would be greatly appreciated.

Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Maybe like this

Code:
Sub test()
Dim ws As Worksheet, newworksheet As Worksheet
Set newworksheet = Worksheets.Add
For Each ws In ActiveWorkbook.Worksheets
    With ws
        If .Name Like "*Detail*" Then
            .UsedRange.Offset(1).Copy
            newworksheet.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
        End If
    End With
Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,182
Messages
6,129,369
Members
449,506
Latest member
nomvula

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