Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default How to move data from many spreadsheets to one

I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to move data from many spreadsheets to one

DaveGB,

Take a look at Ron de Bruin's merge routine and see if it does what you
want:

http://www.rondebruin.nl/merge.htm

Good luck,

RocketDude

"davegb" wrote in message
...
I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default How to move data from many spreadsheets to one

On Nov 26, 3:27*pm, "RocketDude" wrote:
DaveGB,

Take a look at Ron de Bruin's merge routine and see if it does what you
want:

http://www.rondebruin.nl/merge.htm

Good luck,

RocketDude

"davegb" wrote in message

...



I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?- Hide quoted text -


- Show quoted text -


Thanks for your reply. My situation is different and is not a straight
merge. It would take a long time to give the history of how I got to
where I am. Suffice it to say that many mistakes have been made and
now I find myself with 70+ workbooks from which I need to extract the
data from one worksheet in each workbook, paste it into a master
workbook, then run an existing macro to tally the numerical data and
save the text data into the master. Then move on to the next workbook.
It really shouldn't be that difficult, I just need a little help in
figuring out an approach so I don't waste a lot of time going up blind
alleys.

My original question remains: Is it workable to do a For Each on every
workbook in the folder (is this the best, or even a good, way to go
through all the workbooks?), test each in turn to skip opening
ThisWorkboook (the master), copy the data sheet, paste it into the
master data sheet, run the existing macro, close the data workbook and
go on to the next? Can anyone see any obvious reasons why this
wouldn't work?

Thanks in advance!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to move data from many spreadsheets to one

Hi davegb

There is code on this page if the add-in is not what you want
http://www.rondebruin.nl/copy3.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"davegb" wrote in message ...
On Nov 26, 3:27 pm, "RocketDude" wrote:
DaveGB,

Take a look at Ron de Bruin's merge routine and see if it does what you
want:

http://www.rondebruin.nl/merge.htm

Good luck,

RocketDude

"davegb" wrote in message

...



I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?- Hide quoted text -


- Show quoted text -


Thanks for your reply. My situation is different and is not a straight
merge. It would take a long time to give the history of how I got to
where I am. Suffice it to say that many mistakes have been made and
now I find myself with 70+ workbooks from which I need to extract the
data from one worksheet in each workbook, paste it into a master
workbook, then run an existing macro to tally the numerical data and
save the text data into the master. Then move on to the next workbook.
It really shouldn't be that difficult, I just need a little help in
figuring out an approach so I don't waste a lot of time going up blind
alleys.

My original question remains: Is it workable to do a For Each on every
workbook in the folder (is this the best, or even a good, way to go
through all the workbooks?), test each in turn to skip opening
ThisWorkboook (the master), copy the data sheet, paste it into the
master data sheet, run the existing macro, close the data workbook and
go on to the next? Can anyone see any obvious reasons why this
wouldn't work?

Thanks in advance!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to move data from many spreadsheets to one

Adapt to your needs

Sub test()
Dim cnt As Long, i As Long
Dim bIsOpen As Boolean
Dim sFldr As String
Dim colFiles As Collection
Dim wb As Workbook

sFldr = ThisWorkbook.Path & "\"

cnt = FilesToCol(sFldr, colFiles)
If cnt Then
For i = 1 To cnt
Set wb = Nothing
bIsOpen = False
If UCase$(colFiles(i)) < UCase$(ThisWorkbook.Name) Then

On Error Resume Next
Set wb = Workbooks(colFiles(i))
On Error GoTo 0

bIsOpen = Not wb Is Nothing
If Not bIsOpen Then
Set wb = Workbooks.Open(sFldr & colFiles(i))
End If

' do copy stuff with wb here <<<

If Not bIsOpen Then wb.Close False
End If
Next
Else

MsgBox "no files found"
End If

End Sub

Function FilesToCol(sPath As String, c As Collection) As Long
Dim sFile As String

Set c = New Collection
Call Dir("nul")
sFile = Dir(sPath & "*.xls*") '
Do While Len(sFile)
c.Add sFile
sFile = Dir()
Loop
FilesToCol = c.Count
End Function

Regards,
Peter T


"davegb" wrote in message
...
I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default How to move data from many spreadsheets to one

On Wed, 26 Nov 2008 14:17:47 -0800 (PST), davegb wrote:

I have 73 workbooks that I want to copy data from one of the
worksheets and put it all into a single workbook (not one of the 73)
which will then tally the results. Before I can even start to write
code, I have a problem I'm not sure how to deal with. If I write a For
Each loop to open each workbook in the folder in turn, if the tally
workbook is in the same directory, it's going to try to open that one
and, I imagine, will hang the macro because that workbook
(ThisWorkbook) will already be open. So does the tally workbook have
to be in a different directory? Or, can I test each workbook as it is
selected , before it is opened) to see if it's ThisWorkbook and have
it skip ThisWorkbook and go on the the next? Any suggestions as to the
best way to handle this kind of situation?


Thanks to everyone who made suggestions. There's a lot of material here, so
when I get to this later today, I'll go through it and figure out what
works best for me.
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
Why can't I move around spreadsheets with the up and down arrows? Aussie girl Excel Discussion (Misc queries) 1 June 8th 07 09:34 PM
Match and Move Data in 2 Spreadsheets Steve T Excel Discussion (Misc queries) 1 April 20th 07 04:36 AM
How can I move spreadsheets to contain same format and spacing pstein69 Excel Discussion (Misc queries) 2 January 10th 07 05:11 AM
How to move data from spreadsheets to spreadsheet? saltaway Excel Discussion (Misc queries) 2 September 11th 06 06:27 PM
Can i move scanned jpeg text to excel spreadsheets etpconscious Excel Worksheet Functions 4 December 19th 05 12:14 AM


All times are GMT +1. The time now is 09:17 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"