Question : How can I merge multiple worksheets into one worksheet ?

I have an excel workbook with approximately 50 worksheets in it. Each sheet is formatted in the exact same way, A1 contains a row header and A2, A3, A4 etc contain the data. For each sheet the data and column heading are different.

I need to get all the sheets merged into one so that I end up with a master sheet. I need it to be in the following format, Colum A contains everything from the first worksheet, column B contains all the data from sheet 2, column C the data from sheet 3 etc etc.

I've searched far and wide for a solution, but the closest I can get is having all the data from all the worksheets end up in column A, which isn't much use really.

Can anyone throw me some vba that'll do this ?

many thanks in advance for any help

Answer : How can I merge multiple worksheets into one worksheet ?

Hi,

OK, that gave me the answer straight away. This code should be what you are looking for. I was correct in thinking that I had the wrong inmpression of the layout of your data.

Sub ConsolSheets()
Dim ws As Worksheet, i As Long, Shtcnt As Long, x As Long
Shtcnt = ActiveWorkbook.Sheets.Count
Set ws = Sheets.Add(After:=Sheets(Shtcnt))
For i = 1 To Shtcnt
    Sheets(i).Activate
    Range("A1").Select
If Not Intersect(ActiveSheet.UsedRange, Range("A2:IV65536")) Is Nothing Then
    Intersect(ActiveSheet.UsedRange, Range("A2:IV65536")).Select
    If Selection.Cells.Count > 1 Then
        For x = 1 To ActiveSheet.UsedRange.Columns.Count
            Intersect(Selection, Columns(x)).Copy ws.Cells(65536, i).End(xlUp).Offset(1, 0)
        Next
    End If
End If
Next
ws.Activate
End Sub

Cheers,
MalicUK.
Random Solutions  
 
programming4us programming4us