Copying data from diffrent sheets to a new sheet

Kaboki

New Member
Joined
Jul 24, 2018
Messages
4
Hello all,
I use excel version 2007.
I have a excel file consisted of 300 sheets.
How can I write a macro by which rows 1:100 and columns A:K from each sheet to be copied in a new sheet after each other, that means in the new sheet rows 1:100 are copied from rows 1:100 of sheet 1, rows 101:200 are copied from sheet 2, …
What will be the macro of this?
Thanks for you help.
Kaveh
 

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.
Hi & welcome to MrExcel.
How about
Code:
Sub Copyrows()
   Dim Nws As Worksheet, Ws As Worksheet
   
   Set Nws = Sheets.Add.name = "Results"
   For Each Ws In Worksheets
      If Not Ws.name = Nws.name Then
         Ws.Range("A1:K100").Copy Nws.Range("A" & Rows.Count).End(xlUp).Offset(1)
      End If
   Next Ws
End Sub
This assumes that col A will always have data
 
Upvote 0
Code:
Option Explicit


Sub MrE()
    Dim ws As Worksheet, sh As Worksheet
    'Name the Master Worksheet.  Assumes sheet is named Master
    Set sh = Sheets("Master")
    Application.ScreenUpdating = False
    Dim rng As Range, lr As Long
    Set rng = ws.Range("A1:K100")
    For Each ws In Worksheets
        If ws.Name <> "Master" Then
            lr = sh.Range("A" & Rows.Count).End(xlUp).Row
            ws.Range(rng).Copy sh.Range("A" & lr + 1)
        End If
    Next ws
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Action completed"


End Sub
 
Upvote 0
Hi & welcome to MrExcel.
How about
Code:
Sub Copyrows()
   Dim Nws As Worksheet, Ws As Worksheet
   
   Set Nws = Sheets.Add.name = "Results"
   For Each Ws In Worksheets
      If Not Ws.name = Nws.name Then
         Ws.Range("A1:K100").Copy Nws.Range("A" & Rows.Count).End(xlUp).Offset(1)
      End If
   Next Ws
End Sub
This assumes that col A will always have data

Hi,
Thanks for your message. but it didn't work.
Three issues:
1- first rows and colums of my sheets are empty.
2- sheets name are not excel name default. They are numbers.
3- my sheets are from right to left.
 
Upvote 0
Code:
Option Explicit


Sub MrE()
    Dim ws As Worksheet, sh As Worksheet
    'Name the Master Worksheet.  Assumes sheet is named Master
    Set sh = Sheets("Master")
    Application.ScreenUpdating = False
    Dim rng As Range, lr As Long
    Set rng = ws.Range("A1:K100")
    For Each ws In Worksheets
        If ws.Name <> "Master" Then
            lr = sh.Range("A" & Rows.Count).End(xlUp).Row
            ws.Range(rng).Copy sh.Range("A" & lr + 1)
        End If
    Next ws
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Action completed"


End Sub

Hi,
This macro didn't work too.
 
Upvote 0
Try
Code:
Sub Copyrows()
   Dim Nws As Worksheet, Ws As Worksheet
   
   Sheets.Add.Name = "Results"
   Set Nws = ActiveSheet
   For Each Ws In Worksheets
      If Not Ws.Name = Nws.Name Then
         Ws.Range("A1:K100").Copy Nws.Range("D" & Rows.Count).End(xlUp).Offset(1, -3)
      End If
   Next Ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
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