Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pulling data from 3000 files

Hi All,

I'm going crazy try to copy and paste data from 3000 files into 1 file. Is
there a way to automatically open a file, copy columns 1 -5 and then append
it to the file where I want it all placed?

Thanks in advance...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Pulling data from 3000 files


Folder = "c:\temp"
FName = Dir(Folder & "\*.xls")
Set oldbkSht = ThisWorkbook.Sheets("Sheet1")
Do While FName < ""
OldbkLastRow = oldbkSht.Range("A" & Rows.Count).End(xlUp)
Set newbk = Workbooks.Open(Filename:=Folder & "\" & FName)
Set newbkSht = newbk.Sheets("Sheet1")
NewbkLastRow = newbkSht.Range("A" & Rows.Count).End(xlUp)
newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)
newbk.Close
FName = Dir()
Loop

"flounder73" wrote:

Hi All,

I'm going crazy try to copy and paste data from 3000 files into 1 file. Is
there a way to automatically open a file, copy columns 1 -5 and then append
it to the file where I want it all placed?

Thanks in advance...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pulling data from 3000 files

Hi Joel,

Thanks for code...however, I'm having an issue with a part of the code
"newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)"
in that it has a compilation error saying the function is not supported. I
also made a mistake in my post and I need to copy rows 1 - 5 not columns.

Sorry...thanks in advance.

"Joel" wrote:


Folder = "c:\temp"
FName = Dir(Folder & "\*.xls")
Set oldbkSht = ThisWorkbook.Sheets("Sheet1")
Do While FName < ""
OldbkLastRow = oldbkSht.Range("A" & Rows.Count).End(xlUp)
Set newbk = Workbooks.Open(Filename:=Folder & "\" & FName)
Set newbkSht = newbk.Sheets("Sheet1")
NewbkLastRow = newbkSht.Range("A" & Rows.Count).End(xlUp)
newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)
newbk.Close
FName = Dir()
Loop

"flounder73" wrote:

Hi All,

I'm going crazy try to copy and paste data from 3000 files into 1 file. Is
there a way to automatically open a file, copy columns 1 -5 and then append
it to the file where I want it all placed?

Thanks in advance...


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Pulling data from 3000 files

Hi Flounder73,

I suspect that

newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)


was intended as

newbk.Range("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)

Ron de Bruin has an extensive set of sample
routines for copying and merging data from
multiple files at:

Copy/Paste/Merge examples
http://www.rondebruin.nl/tips.htm

Given the large number of files cited in your
question, you may wish to consider Ron's
techniques for copying data from closed files.
See:

Copy a range from closed workbooks (ADO)
http://www.rondebruin.nl/ado.htm

Ron also offers his RDBMerge Add-in which
enables the merge operation to be performed
with a few mouse clicks. |Details of the Add-in
and a download link may be found at

RDBMerge Add-in
http://www.rondebruin.nl/merge.htm



---
Regards.
Norman


"flounder73" wrote in message
...
Hi Joel,

Thanks for code...however, I'm having an issue with a part of the code
"newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)"
in that it has a compilation error saying the function is not supported.
I
also made a mistake in my post and I need to copy rows 1 - 5 not columns.

Sorry...thanks in advance.

"Joel" wrote:


Folder = "c:\temp"
FName = Dir(Folder & "\*.xls")
Set oldbkSht = ThisWorkbook.Sheets("Sheet1")
Do While FName < ""
OldbkLastRow = oldbkSht.Range("A" & Rows.Count).End(xlUp)
Set newbk = Workbooks.Open(Filename:=Folder & "\" & FName)
Set newbkSht = newbk.Sheets("Sheet1")
NewbkLastRow = newbkSht.Range("A" & Rows.Count).End(xlUp)
newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)
newbk.Close
FName = Dir()
Loop

"flounder73" wrote:

Hi All,

I'm going crazy try to copy and paste data from 3000 files into 1 file.
Is
there a way to automatically open a file, copy columns 1 -5 and then
append
it to the file where I want it all placed?

Thanks in advance...



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Pulling data from 3000 files

Should be
newbk.Rows("1:" & NewbkLastRow).Copy _
Destination:=oldbkSht.Rows(OldbkLastRow + 1)

The source and destination must be consistant. In this case both rows. You
can't mix Rows and Range like Norman suggested.

"Norman Jones" wrote:

Hi Flounder73,

I suspect that

newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)


was intended as

newbk.Range("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)

Ron de Bruin has an extensive set of sample
routines for copying and merging data from
multiple files at:

Copy/Paste/Merge examples
http://www.rondebruin.nl/tips.htm

Given the large number of files cited in your
question, you may wish to consider Ron's
techniques for copying data from closed files.
See:

Copy a range from closed workbooks (ADO)
http://www.rondebruin.nl/ado.htm

Ron also offers his RDBMerge Add-in which
enables the merge operation to be performed
with a few mouse clicks. |Details of the Add-in
and a download link may be found at

RDBMerge Add-in
http://www.rondebruin.nl/merge.htm



---
Regards.
Norman


"flounder73" wrote in message
...
Hi Joel,

Thanks for code...however, I'm having an issue with a part of the code
"newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)"
in that it has a compilation error saying the function is not supported.
I
also made a mistake in my post and I need to copy rows 1 - 5 not columns.

Sorry...thanks in advance.

"Joel" wrote:


Folder = "c:\temp"
FName = Dir(Folder & "\*.xls")
Set oldbkSht = ThisWorkbook.Sheets("Sheet1")
Do While FName < ""
OldbkLastRow = oldbkSht.Range("A" & Rows.Count).End(xlUp)
Set newbk = Workbooks.Open(Filename:=Folder & "\" & FName)
Set newbkSht = newbk.Sheets("Sheet1")
NewbkLastRow = newbkSht.Range("A" & Rows.Count).End(xlUp)
newbk.Rows("A1:E" & NewbkLastRow).Copy _
Destination:=oldbkSht.Row(OldbkLastRow + 1)
newbk.Close
FName = Dir()
Loop

"flounder73" wrote:

Hi All,

I'm going crazy try to copy and paste data from 3000 files into 1 file.
Is
there a way to automatically open a file, copy columns 1 -5 and then
append
it to the file where I want it all placed?

Thanks in advance...






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
Pulling Data, References and Flat Files GF08 Excel Discussion (Misc queries) 1 November 19th 09 10:19 PM
Pulling data from multiple files Whois Clinton Excel Discussion (Misc queries) 5 June 9th 08 02:46 PM
Pulling Information from emails/files jbaranski[_2_] Excel Programming 0 July 27th 06 08:39 PM
Pulling files in using Macros MSHO Excel Programming 5 January 11th 06 03:21 PM
How do I link the spreadsheet with data in MS Money 3000? RWRoberts Excel Programming 2 February 7th 05 02:41 PM


All times are GMT +1. The time now is 05:48 AM.

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

About Us

"It's about Microsoft Excel"