Excel guru's Please help..

smartguy

Well-known Member
Joined
Jul 14, 2009
Messages
778
Hi all,

I have 20 sheet in the Excel file. in the below Format.

i want collate all the sheet in to 1 sheet.


Excel Workbook
ABCDEF
1countrymoviemovietheratesumatime
2usaaaaaaaaa
3usaaaaaaaaa
4usaaaaaaaaa
5usaaaaaaaaa
6usaaaaaaaaa
7usaaaaaaaaa
8usaaaaaaaaa
9usaaaaaaaaa
Sheet1
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
add a header row to the master sheet and try this code

Rich (BB code):
Sub Copy_to_Master()

Dim sh1 As Integer, lastrow As Long, ws As Worksheet
sh1 = Worksheets("Master").Index   'change to your master sheet name
For Each ws In Worksheets
    lastrow = Worksheets(sh1).UsedRange.Rows.Count
    If ws.Index <> sh1 Then
        With ws
            .Activate
            .Range("A2", .UsedRange.End(xlToRight).End(xlDown).Address).Copy
        End With
        Worksheets(sh1).Cells(lastrow + 1, 1).PasteSpecial xlPasteValues
        Application.CutCopyMode = False
    End If
Next ws
Worksheets(sh1).Activate
End Sub

Im not good at VBA, better solutions might be there
 
Upvote 0
See if next code could help.
Adapt to your needs.
It assume that the header is already present in sheet "All"
Code:
Sub CopyToMaster()
Dim wkSht As Worksheet
Dim DestSht As Worksheet
Dim DestRow As Long
    Set DestSht = Sheets("All")
    DestRow = DestSht.Range("A" & Rows.Count).End(xlUp).Row + 1
    For Each wkSht In Worksheets
        If Not wkSht Is DestSht Then
            With wkSht
                .UsedRange.Offset(1, 0).Copy Destination:=DestSht.Cells(DestRow, 1)
            End With
        End If
        DestRow = DestSht.Range("A" & Rows.Count).End(xlUp).Row + 1
    Next wkSht
End Sub
 
Last edited:
Upvote 0
in which line?

did you add header row to your master sheet?

did you change the master sheet name in the code to match the actual name?
 
Upvote 0
where did you put the code?

code you post the code that you revised to suit your need?
 
Upvote 0
smartguy,
You could be smart enought to help people wanting to help you:
What is the code statement where the error occurs?
Where did you put the macro: Module or sheet's code
How did you ran the code
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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