Coping multiplw worksheets into one


Posted by S Dennison on May 13, 2001 12:50 PM

I have a workbook that contains multiple worksheets how can I quickly combine them into one worksheet.

Posted by Dave Hawley on May 13, 2001 2:06 PM

Hi S Dennison


This code will do it for you.


Sub CombineWshts()
'Written by OzGrid Business Applications
'www.ozgrid.com
Dim Wsht As Worksheet
On Error Resume Next
Application.DisplayAlerts = False
Sheets.Add().Name = "AllSheets"
If ActiveSheet.Name <> "AllSheets" Then ActiveSheet.Delete
Application.ScreenUpdating = False

For Each Wsht In ActiveWorkbook.Worksheets
If Wsht.Name <> "AllSheets" Then
Wsht.UsedRange.Copy
Sheets("AllSheets").Cells.SpecialCells _
(xlCellTypeLastCell).Offset(1, 0).End(xlToLeft).PasteSpecial xlValues
End If
Next Wsht

Application.DisplayAlerts = True
Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

Dave


OzGrid Business Applications

Posted by s dennison on May 15, 2001 6:28 AM

Dave,

I tried this code but, I can not get it to work. When I step thru it is looping thru each spreadsheet it just is not copying it to the new one? Do you have any suggestions?

Thanks for all your help!



Posted by S Dennison on May 15, 2001 7:05 AM

Dave Thanks!!!!

Dave,

I was able to get this to work!!! Thank you for your help. I had been tring to acomplish this for about a week!!!!

S Dennison