Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Combining data from multiple worksheets into one

I have 4 files with hundreds of worksheets in each file. I need to combine
all 700,000 rows of data from all the worksheets in these 4 files into one
worksheet to take into Access to append additional data.
Is there a way to do this without cutting and pasting the data from each
individual worksheet into the single list?
I'm using Office 07 and although the data is the same format in each of the
worksheets the entries vary in the number of rows from sheet to sheet.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default Combining data from multiple worksheets into one

Mark
This macro will do what you want. The following conditions must be met for
this to work.
The 4 workbooks must all be in one folder.
The workbook into which you want the 4 workbooks combined must contain this
macro and must also be in that same folder.
The 4 workbooks' names must all have an extension of ".xlsx".
The workbook that contains this macro must have an extension of ".xlsm".
No other workbooks with the ".xlsx" extension should be in this same folder.
This macro loops through the 4 workbooks, and in each workbook loops through
all the sheets, and copies all the data from A2 down and 10 columns wide and
pastes it into the workbook that holds this macro. Make changes to the code
as needed to fit with your data. Come back if you need more. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook, wbMaster As Workbook
Dim TheFile As String, MyPath As String
Dim ws As Worksheet, Dest As Range
Set Dest = Range("A2")
Set wbMaster = ThisWorkbook
MyPath = ThisWorkbook.Path
ChDir MyPath
TheFile = Dir("*.xlsx")
Do While TheFile < ""
If TheFile < wbMaster.Name Then
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
For Each ws In wb.Worksheets
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 10).Copy Dest
End With
Set Dest = wbMaster.Range("A" &
Rows.Count).End(xlUp).Offset(1)
Next ws
wb.Close
End If
TheFile = Dir
Loop
End Sub


"Mark712" wrote in message
...
I have 4 files with hundreds of worksheets in each file. I need to combine
all 700,000 rows of data from all the worksheets in these 4 files into one
worksheet to take into Access to append additional data.
Is there a way to do this without cutting and pasting the data from each
individual worksheet into the single list?
I'm using Office 07 and although the data is the same format in each of
the
worksheets the entries vary in the number of rows from sheet to sheet.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Combining data from multiple worksheets into one

Otto,
Thank you for the macro, this will save an incredible amount of time. I'll
try it tomorrow.

Mark

"Otto Moehrbach" wrote:

Mark
This macro will do what you want. The following conditions must be met for
this to work.
The 4 workbooks must all be in one folder.
The workbook into which you want the 4 workbooks combined must contain this
macro and must also be in that same folder.
The 4 workbooks' names must all have an extension of ".xlsx".
The workbook that contains this macro must have an extension of ".xlsm".
No other workbooks with the ".xlsx" extension should be in this same folder.
This macro loops through the 4 workbooks, and in each workbook loops through
all the sheets, and copies all the data from A2 down and 10 columns wide and
pastes it into the workbook that holds this macro. Make changes to the code
as needed to fit with your data. Come back if you need more. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook, wbMaster As Workbook
Dim TheFile As String, MyPath As String
Dim ws As Worksheet, Dest As Range
Set Dest = Range("A2")
Set wbMaster = ThisWorkbook
MyPath = ThisWorkbook.Path
ChDir MyPath
TheFile = Dir("*.xlsx")
Do While TheFile < ""
If TheFile < wbMaster.Name Then
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
For Each ws In wb.Worksheets
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 10).Copy Dest
End With
Set Dest = wbMaster.Range("A" &
Rows.Count).End(xlUp).Offset(1)
Next ws
wb.Close
End If
TheFile = Dir
Loop
End Sub


"Mark712" wrote in message
...
I have 4 files with hundreds of worksheets in each file. I need to combine
all 700,000 rows of data from all the worksheets in these 4 files into one
worksheet to take into Access to append additional data.
Is there a way to do this without cutting and pasting the data from each
individual worksheet into the single list?
I'm using Office 07 and although the data is the same format in each of
the
worksheets the entries vary in the number of rows from sheet to sheet.

.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Combining data from multiple worksheets into one

Otto,
On the line, .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Resize(,
10).Copy Dest, I'm getting an error message that says "Copy Method of Range
Calss failed". Any ides what would cause that?

Mark

"Otto Moehrbach" wrote:

Mark
This macro will do what you want. The following conditions must be met for
this to work.
The 4 workbooks must all be in one folder.
The workbook into which you want the 4 workbooks combined must contain this
macro and must also be in that same folder.
The 4 workbooks' names must all have an extension of ".xlsx".
The workbook that contains this macro must have an extension of ".xlsm".
No other workbooks with the ".xlsx" extension should be in this same folder.
This macro loops through the 4 workbooks, and in each workbook loops through
all the sheets, and copies all the data from A2 down and 10 columns wide and
pastes it into the workbook that holds this macro. Make changes to the code
as needed to fit with your data. Come back if you need more. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook, wbMaster As Workbook
Dim TheFile As String, MyPath As String
Dim ws As Worksheet, Dest As Range
Set Dest = Range("A2")
Set wbMaster = ThisWorkbook
MyPath = ThisWorkbook.Path
ChDir MyPath
TheFile = Dir("*.xlsx")
Do While TheFile < ""
If TheFile < wbMaster.Name Then
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
For Each ws In wb.Worksheets
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 10).Copy Dest
End With
Set Dest = wbMaster.Range("A" &
Rows.Count).End(xlUp).Offset(1)
Next ws
wb.Close
End If
TheFile = Dir
Loop
End Sub


"Mark712" wrote in message
...
I have 4 files with hundreds of worksheets in each file. I need to combine
all 700,000 rows of data from all the worksheets in these 4 files into one
worksheet to take into Access to append additional data.
Is there a way to do this without cutting and pasting the data from each
individual worksheet into the single list?
I'm using Office 07 and although the data is the same format in each of
the
worksheets the entries vary in the number of rows from sheet to sheet.

.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default Combining data from multiple worksheets into one

Mark
I set up some files in the same folder as the file with the macro and it
runs fine except for this line:
Set Dest = wbMaster.Range("A" & Rows.Count).End(xlUp).Offset(1)
Change it to:
Set Dest = wbMaster.ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1)
Now to your problem. Did the macro do ANY copying at all? If not, then you
got the error in the first loop.
If you wish, make copies of all 5 of your files and delete most of your data
& sheets in those 5 copies so the whole mass will be smaller. I need jut a
couple of sheets in each file and a dozen rows of data in each sheet. Run
the macro and confirm that you still get that error. Then send me those 5
files and I'll try to figure it out for you. My email is
. Remove the "extra" from this email address.
HTH Otto
"Mark712" wrote in message
...
Otto,
On the line, .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Resize(,
10).Copy Dest, I'm getting an error message that says "Copy Method of
Range
Calss failed". Any ides what would cause that?

Mark

"Otto Moehrbach" wrote:

Mark
This macro will do what you want. The following conditions must be met
for
this to work.
The 4 workbooks must all be in one folder.
The workbook into which you want the 4 workbooks combined must contain
this
macro and must also be in that same folder.
The 4 workbooks' names must all have an extension of ".xlsx".
The workbook that contains this macro must have an extension of ".xlsm".
No other workbooks with the ".xlsx" extension should be in this same
folder.
This macro loops through the 4 workbooks, and in each workbook loops
through
all the sheets, and copies all the data from A2 down and 10 columns wide
and
pastes it into the workbook that holds this macro. Make changes to the
code
as needed to fit with your data. Come back if you need more. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook, wbMaster As Workbook
Dim TheFile As String, MyPath As String
Dim ws As Worksheet, Dest As Range
Set Dest = Range("A2")
Set wbMaster = ThisWorkbook
MyPath = ThisWorkbook.Path
ChDir MyPath
TheFile = Dir("*.xlsx")
Do While TheFile < ""
If TheFile < wbMaster.Name Then
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
For Each ws In wb.Worksheets
With ws
.Range("A2", .Range("A" &
Rows.Count).End(xlUp)).Resize(, 10).Copy Dest
End With
Set Dest = wbMaster.Range("A" &
Rows.Count).End(xlUp).Offset(1)
Next ws
wb.Close
End If
TheFile = Dir
Loop
End Sub


"Mark712" wrote in message
...
I have 4 files with hundreds of worksheets in each file. I need to
combine
all 700,000 rows of data from all the worksheets in these 4 files into
one
worksheet to take into Access to append additional data.
Is there a way to do this without cutting and pasting the data from
each
individual worksheet into the single list?
I'm using Office 07 and although the data is the same format in each of
the
worksheets the entries vary in the number of rows from sheet to sheet.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combining data from multiple worksheets into one yowzers Excel Worksheet Functions 4 December 26th 09 04:45 PM
combining data multiple worksheets into one? kamartin Excel Discussion (Misc queries) 5 February 10th 09 11:50 PM
Combining data from multiple worksheets into master worksheet Jill Excel Worksheet Functions 1 February 3rd 09 11:29 PM
Combining data from multiple worksheets. Olmsted57 Excel Discussion (Misc queries) 7 August 1st 07 01:12 AM
Combining data from multiple worksheets and separate spreadsheets kfletchb Excel Discussion (Misc queries) 1 August 10th 06 07:53 PM


All times are GMT +1. The time now is 06:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"