Copy first row of data from all worksheets onto one

leeksleeks

Board Regular
Joined
Oct 31, 2013
Messages
96
Hi,

I am needing a VBAcode that will copy data from Cells A1:G1 on all worksheets and paste this onto one 'Results' worksheet. I have a file without thousands of worksheets on them but the data is only on the first row.

Any help you be greatly appreciated.

Cheers,

Alex
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Add this code to a module in the workbook you want to combine data from. This assumes a results sheet already exists.

Code:
Sub combinesheets()
    Dim wsCopy As Worksheet, wsPaste As Worksheet
    Set wsPaste = Sheets("Results")
    Dim rPaste As Range
    Set rPaste = wsPaste.Range("A" & wsPaste.Rows.Count).End(xlUp)
    If rPaste <> "" Then rPaste = rPaste.Offset(1)


    For Each wsCopy In ThisWorkbook.Worksheets
        If wsCopy.Name <> "Results" Then
            wsCopy.Range("A1:G1").Copy rPaste
            Set rPaste = rPaste.Offset(1)
        End If
    Next wsCopy
End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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