Hello my first post,
First of all great place, I plan to spend a lot of time here, because I'm new to excel and I need to know many things.
I will be very thankful for help ...
Here is what I need.I have several excel files, and I want to create one from them.First option is copy past but that is time consuming, so is there any other way.
So lets say that is my first file:
A B
a1 b1
a2 b2
And let's say that is my second file
A B
a3 b3
s f
v h
So I want to create this one
A B
a1 b1
a2 b2
a3 b3
s f
v h
Is there a way, please?I have many excel files that are in one directory.
Last edited by bodmov; 03-13-2010 at 04:40 AM.
BodMov,
Welcome to the forum. As you are an inexperienced excel user I would do the following.
Have all files open including the consolidation file.
When you right click a tab (bottum) you can copy/move it to the consolidation file.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Hi BodMov, this will be a VBA question, in case you didn't realize. I have a stock macro to import all the files in a folder into a single stacked worksheet. Here's the code:
========Code:Sub Consolidate() 'Author: JBeaucaire' 'Date: 9/15/2009 (2007 compatible)' 'Summary: Open all Excel files in a specific folder and merge data' ' into one master sheet (stacked)' ' Moves imported files into another folder' Dim fName As String, fPath As String, fPathDone As String, OldDir As String Dim LR As Long, NR As Long Dim wbkOld As Workbook, wbkNew As Workbook, ws As Worksheet 'Setup' Application.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Set wbkNew = ThisWorkbook wbkNew.Activate Sheets("Master").Activate 'sheet report is built into' If MsgBox("Import new data to this report?", vbYesNo) = vbNo Then Exit Sub If MsgBox("Clear the old data first?", vbYesNo) = vbYes Then Cells.Clear NR = 1 Else NR = Range("A" & Rows.Count).End(xlUp).Row + 1 End If 'Path and filename' OldDir = CurDir 'memorizes the current working path' fPath = "C:\2010\" fPathDone = "C:\2010\Imported\" ChDir fPath fName = Dir("*.xl*") 'filtering key, change to suit' 'Import a sheet from found file' Do While Len(fName) > 0 'Open file' Set wbkOld = Workbooks.Open(fName) 'Find last row and copy data' LR = Range("A" & Rows.Count).End(xlUp).Row Range("A1:A" & LR).EntireRow.Copy _ wbkNew.Sheets("Master").Range("A" & NR) 'close file' wbkOld.Close False 'Next row' NR = Range("A" & Rows.Count).End(xlUp).Row + 1 'move file to IMPORTED folder' Name fPath & fName As fPathDone & fName 'ready next filename' fName = Dir Loop 'Cleanup' ActiveSheet.Columns.AutoFit Application.DisplayAlerts = True Application.EnableEvents = True Application.ScreenUpdating = True 'restores original working path' ChDir OldDir End Sub
SETUP:
1) Edit the code above so the fPath is where your files to import exists.
2) On your computer, create another folder inside that path call Imported, and then make sure that path is listed in the code for the fPathDone variable.
3) Put the macro into your report workbook:
How/Where to install the macro:
A. Open up your report workbook
B. Get into VB Editor (Press Alt+F11)
C. Insert a new module (Insert > Module)
D. Copy and Paste in your code (given above)
E. Get out of VBA (Press Alt+Q)
F. Save your sheet in a different directory from the import files, or save it into the ...\IMPORTED folder.
The macro is installed and ready to use.
=======
USAGE:
Press Alt-F8 and select Consolidate from the macro list.
Last edited by JBeaucaire; 03-09-2010 at 04:34 AM.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
thanks rwgrietveld
actually you mean to copy paste the files one by one, or ...
yes that is possible but I have a lot of information and it will takes me a lot of time.i have to copy/paste more than 100 files every day...
so is there easier option for me , please
BodMov,
I didn't want to direct you to VBA just yet, but like JB states: inescapable VBA
Use JB's solution. That's the best approach when dealing with >100 files per day.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
JBeaucaire Thank you really much.
I followed your steps, but I get this error:
Run-time error '9'
Subscript out of range
In debug mode:
Sheets("Master").Activate 'sheet report is built into'
this is highlited with yellow
What to do???
Either create a sheet in you workbook called Master
or
Change that line of code and put in the sheetname you want used.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thanks again but it does not works,
I got this messages when I run the macro:
Import new data to this report? Yes No
Clear the old data first?Yes Not
I clicked yes yes but nothing appears.What else can I do.I think I almost do it ...
The next error that I see in debud is :
Name fPath & fName As fPathDone & fName
actually where do I have to see my new excel document?
Last edited by bodmov; 03-09-2010 at 06:59 AM.
VBA is a tough nut to crack for the first time. Let's start over.
Tell me:
1) The name of the SHEET in your workbook you want to compile this report into. In my macro it's called Master...
2) The complete path to the folder where your 100s of files will be
3) How many sheets are in those 100s of files? Can we simply import the active sheet when each one opens?
If not, what is the sheet name you want imported from those files?
4) Do the import sheets have titles in row1? Do those need to be skipped or can we just import it all?
5) Have you created another folder called IMPORT inside the path that holds the files?
NOTE: When you run this macro from inside the Report workbook, that workbook needs to running from a different path than your import files. I've seen in the past where people put the report into the same folder...it imports all the files and then gets to the report file itself and reopens it...effectively erasing the work already done. Oops.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thank you so much for your help.
As i mentioned before I'm new to excel.I've been using excel for several days...
Here is what I did?
C:\Documents and Settings\Administrator\My Documents\1\3
C:\Documents and Settings\Administrator\My Documents\1\3\Imported
Actually where do I have to put all of my files, and where will appear the result?Will I have to create any excel where I expect the result or it will just be created?Is so what name?
I saved the macro in different directory
"1) The name of the SHEET in your workbook you want to compile this report into. In my macro it's called Master..."
Sheet1
, but I'm not sure I know what exactly is report workbook
3) How many sheets are in those 100s of files? Can we simply import the active sheet when each one opens?
Actually I have many excel files with only one sheet of data.
4) Do the import sheets have titles in row1? Do those need to be skipped or can we just import it all?
no everything should be imported
Here, just take this workbook and save it somewhere, open it and run the Consolidate macro.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
I don't want what to tell you
IT REALLY WORKS
THANK YOU !!!
Glad to hear it.
If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Hi of course I'll do that , but I have last question,
Actually it worked but I'm trying to consolidate files from this site:
https://adwords.google.com/select/KeywordToolExternal
and I noticed that it works only with some types of files (I'm not sure)
What I mean is when I create excel documents only with letters it works perfectly, but when I use excel files extracted from this site (they have also numbers), it does not works ...
I'm not sure what is the problem.Is it works if there are numbers in it, or maybe the format can be the problem.
Kindly go to that site enter any keywords, click you'll see:
Download all keywords: text, .csv (for excel), .csv
Download cvs, and tell me is that the same format and what can be the problem it does not work with such a files.
Many thanks again ...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks