ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   merging different worksheets in a workbook to one sheet (https://www.excelbanter.com/excel-worksheet-functions/15449-merging-different-worksheets-workbook-one-sheet.html)

a.pontes

merging different worksheets in a workbook to one sheet
 
Is there a macro that I can take a work book that has 8 seperate worksheets
of data, and put all the data on one worksheet?. I need to sort all the data
on one sheet. Currently I cut and paste the data to the one sheet.
Any help would be appreciated.
Thanks,
AP



Mohamed Shafiee

Hi there...

This will work.

Shafiee.

Sub MakeOneSheet()
Dim strpasterange As String
Dim wbk As Excel.Workbook
Dim awbk As Excel.Workbook
Set awbk = ActiveWorkbook
Set wbk = Application.Workbooks.Add
For i = 1 To ActiveWorkbook.Sheets.Count
strpasterange = "'[" & wbk.Name & "]" & wbk.Sheets(1).Name & "'!A" &
wbk.Sheets(1).UsedRange.Rows.Count + 1
With awbk.Sheets(i)
.UsedRange.Copy Range(strpasterange)
End With
Next

Set wbk = Nothing
Set awbk = Nothing
End Sub

"a.pontes" wrote in message
...
Is there a macro that I can take a work book that has 8 seperate

worksheets
of data, and put all the data on one worksheet?. I need to sort all the

data
on one sheet. Currently I cut and paste the data to the one sheet.
Any help would be appreciated.
Thanks,
AP






All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com