Combining worksheets into summary with source worksheet

odonnke19

New Member
Joined
Oct 17, 2007
Messages
8
Morning, I tried the combine VBA below worked perfectly however it did not list the name of the worksheet ie. 18-01-01.xls as I thought it would. Any advice? I have over 104 tab/worksheets
Sub Combine()


Dim J As Integer


On Error Resume Next


Sheets(1).Select


Worksheets.Add


Sheets(1).Name = "Combined"


Sheets(2).Activate


Range("A1").EntireRow.Select


Selection.Copy Destination:=Sheets(1).Range("A1")


For J = 2 To Sheets.Count


Sheets(J).Activate


Range("A1").Select


Selection.CurrentRegion.Select


Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select


Selection.Copy Destination:=Sheets(1).Range("A1048575").End(xlUp)(2)


Next


End Sub
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,618
Office Version
  1. 2007
Platform
  1. Windows
Check if the following is useful to put the name of the sheet in column A

VBA Code:
Sub Combine()
  Dim J As Integer, lr As Long, lr2 As Long
  Sheets(1).Select
  Worksheets.Add
  Sheets(1).Name = "Combined"
  Sheets(2).Activate
  Range("A1", Cells(1, Columns.Count).End(1)).Copy Sheets(1).Range("B1")
  For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    lr = Sheets(1).Range("A" & Rows.Count).End(3)(2).Row
    Selection.Copy Destination:=Sheets(1).Range("B" & lr)
    lr2 = Sheets(1).Cells.Find("*", , xlValues, , xlByRows, xlPrevious).Row
    Sheets(1).Range("A" & lr & ":A" & lr2).Value = Sheets(J).Name
  Next
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,618
Office Version
  1. 2007
Platform
  1. Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,956
Messages
5,621,809
Members
415,857
Latest member
braunReivn

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
Top