VBA needed

priscilla_absi

New Member
Joined
Dec 26, 2013
Messages
2
Hello,I have a worksheet that contains 40 sheets.Those sheets have the same header (column A till Q). The data in those sheets will be added consecutively. An additional sheet was created at the beginning of the workbook, which should serve as a summary one. It should contain the data present in all the sheets' column A till F. I need please some help in creating a vba code for the job to be completed...Thank you,
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Not exactly sure what you mean by
The data in those sheets will be added consecutively
but try the code below on a copy of your workbook.
Change the sheetname Summary to your Summary sheets name.
The code goes in a regular module

Code:
Sub Summary()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Summary" Then
            ws.Range("A2:F" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row).Copy _
                    Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1)
        End If
    Next
End Sub

Edit: but also have a read of the link VoG posted while I was typing.
 
Upvote 0
Thank you for your posts.

Mark,
your code worked but can you help me change it for the data copied on the summary sheet does not include the first row (meaning all the rows except the header)
What I meant by "The data in those sheets will be added consecutively": Can the code run automatically so whenever I type in one of the rows of a certain sheet, the data appears on the blank row on the summary sheet?

Thanks a lot!
 
Upvote 0
your code worked but can you help me change it for the data copied on the summary sheet does not include the first row
If you want a header row than try the code below, it takes the header from the second tab in so if the second sheet is the summary sheet then you will need to change the number in Sheets(2).
Code:
Sub Summary()
    Dim ws As Worksheet
    Sheets("Summary").Range("A1:F1").Value = Sheets(2).Range("A1:F1").Value
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Summary" Then
            ws.Range("A2:F" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row).Copy _
                    Sheets("Summary").Range("A" & Sheets("Summary").Rows.Count).End(xlUp).Offset(1)
        End If
    Next
End Sub

If you want the headers copied for every sheet then change the A2 to A1 in this line (but I can't believe that is what you want)
Code:
   ws.Range("[COLOR="#FF0000"]A2[/COLOR]:F" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row).Copy _
                    Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1)

Can the code run automatically so whenever I type in one of the rows of a certain sheet, the data appears on the blank row on the summary sheet?
The code below will copy the row when you double click the cell in Column F.
The code needs to go in the worksheet module i.e. right click the Sheet tab and click view code.
The code needs to go in the tab of every sheet bar the summary tab.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Cells.Count > 1 Then Exit Sub
    If Target.Column = 6 Then
        If Target.Cells.Value <> "" Then
            Range(Cells(Target.Row, 1), Cells(Target.Row, "F")).Copy _
                    Sheets("Summary").Range("A" & Sheets("Summary").Rows.Count).End(xlUp).Offset(1)
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,222
Messages
6,129,589
Members
449,520
Latest member
TBFrieds

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