Hi Everyone,
Sorry for the title I wasn't sure how to word it but here goes I have uploaded only one sheet which I have users in my team completing and they all have individual folders
For example
Adam has a folder and in that is the spreadsheet
Cameron has a folder and in that is the same spreadsheet but different data
and this goes on for 4 teams and about 40 agents
Now here is the question and I'm sorry for babbling but is there an easy way or macro or anything I can make I want a main sheet to be able to go out and collect all the data from all workbooks from the status tab for the 1st and 2nd etc..
Can someone please suggest how I can do this or what I can please do please and I'm kinda needing this for my teams in a few days and I have tried everything I know..
Sorry to bug everyone
Thanks
Ads
I know it sounds cumbersome, but this sounds like the kind of thing you would only have to type ONE formula accurately for each agent to get the data for one particular cell to appear in your workbook. As long as you keep the cell reference relative, you can then copy that cell downward to get the rest of the stats for that agent into your workbook.
That would enable you to collect the values into your master workbook and then do the percentage calculations locally.
Does that make sense? It's a little work, but it's only a one-time setup, then the formulas are there and working forever, yes?
For example:
='C:\My Documents\Jerry\[Test.xls]Stats'!D3
_________________
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 am trying something similar. I want to look up 6 cells from each file in my directory. I would happily do it just using excel but this falls apart when you have many hundreds of cells - one cannot type all those formulae! What I hoped I could do would be to create a directory list (which is easily done) which would tell me the full path to each workbook. I would then concatenate this with the sheet and cell references I want. But that does not work because whilst I can get the right formula to show, that is the result, not the formula in the cell. I have to copy and paste it as a value in order to get it to actually reference the correct thing. Even then, excel often complains about the link and asks me to update it.
Anyhow, a bit of playing and it seems not too difficult to use VBA to do the whole thing (concatenate the string and paste as "=string"). This is not without a bit of trouble because the directory list returns the file path but the link one pastes needs square brackets! I am still hoping someone might be able to tell me an easy way - I remain shocked that it is as easy as pie to find the name and details of every single file but it becomes awfully difficult to get it to tell you the value of sheet1A1 in those same files!
ps. If you did get it working, how does it go in terms of reliability? I am a bit concerned having a large number of links in a single sheet.... i do find excel can be a tad flakey at the best of times!
Two things...
1) If you want to do an "on the fly" report, we can create a macro that
....opens every file in a specific folder
....copies data from specific cells into your "report" row by row
....runs "on demand" so you can collect this data when you wish
....or, runs "when opened" so anytime you open the report it collects the data for you
2) I can help you tweak your existing code to properly insert a series of formulae row by row for each workbook in a folder
I agree that one workbook with that many remote links may be more prone to error, but that's from the hip. It may be fine.
If it were me, I'd be creating a "flat" report that I call "on demand". If you agree, give me:
1) The path with the files
2) All files in that folder? Or just specific files (give me the filtering instructions in the name)
3) A list of the cells you want to grab (and what they are so we know what to title those columns)
4) The report itself...it should be completely new each time or append to the bottom?
Don't skip any of those questions.
_________________
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 for your help!
1) The path is d:\Archem\Adam mixes
2) All files (if it is easy, filtering would be good such that it would only look at files which have a "-" in the title, just in case something else gets put in there).
3) Sheet "cost summary", cell A5 which would be titled 'cost' (there are others but I would not wish to waste your time, once I see how you are doing it, I can replicate for the other cells I would want to retrieve).
4) Whether to renew or append I am unsure. I am assuming that it is probably easier to just renew rather than append.... either way would work for me. Whichever is easier I guess.
I would anticipate that the report would have column A giving the title of the workbook and then B as giving the cost. Again, once I see how it is done, I would then tweak it to retrieve other cells and place them in the right spot with an offset to column B.
Many thanks
Here's a variation on my standard Consolidation macro. I shows you how to setup the first 4 columns in your Summary report. Be sure to edit the line underlined to the correct sheet name for your consolidation report.
(Original macro)Code:Option Explicit Sub Consolidate() 'Author: Jerry Beaucaire' 'Date: 4/16/2010 (2007 compatible) 'Summary: Open all Excel files in a specific folder and imports ' key date into a Summary sheet, one row of data per workbook Dim fName As String, fPath As String, OldDir As String Dim NR As Long Dim wbData As Workbook, wbkNew As Workbook 'Setup Application.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Set wbkNew = ThisWorkbook wbkNew.Activate Sheets("Summary").Activate 'sheet report is built into, edit to correct sheet name If MsgBox("Import new data to this report?", vbYesNo) = vbNo Then Exit Sub Cells.Clear Range("A1:D1").Value = [{"Workbook","Cost","Data1","Data2","Data3"}] NR = 2 'Path and filename (edit this section to suit) fPath = "D:\Archem\Adam mixes\" 'remember final \ in this string OldDir = CurDir 'memorizes the users current working path ChDir fPath 'activate the filepath with files to import fName = Dir("*-*.xls") 'start a listing of desired files, edit the filter as desired 'Import a sheet from found file Do While Len(fName) > 0 If fName <> wbkNew.Name Then 'make sure this file isn't accidentally reopened 'Open file Set wbData = Workbooks.Open(fName) 'This is the section to customize, replace with your own action code as needed With wbkNew.Sheets("Summary") .Range("A" & NR) = wbkNew.Name .Range("B" & NR) = Sheets("Cost Summary").Range("A5") .Range("C" & NR) = Sheets("Cost Summary").Range("C7") .Range("D" & NR) = Sheets("Cost Summary").Range("E15") End With 'close file wbData.Close False 'Next row NR = NR + 1 'ready next filename fName = Dir End If Loop ErrorExit: 'Cleanup ActiveSheet.Columns.AutoFit Application.DisplayAlerts = True 'turn system alerts back on Application.EnableEvents = True 'turn other macros back on Application.ScreenUpdating = True 'refreshes the screen ChDir OldDir 'restores users original working path End Sub
_________________
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, that seems like exactly what I am after. I have had a quick play without much luck - Nothing actually gets imported so I am assuming that something is stopping the macro from managing to find the files it should. I will play further later on.
I have had a chance to have a good mess around now and it is all working brilliantly. I have ti conditionally formatting and such to make the result lool nice but there is one thing I cannot seem to manage. How do I insert a hyperlink to the files in the list? I can insert the full path, I can even convert it within excel into a hyperlink, but no luck directly from the vba.
So I would like the hyperlink to wbdata.path (I guess) with the displayed text being wbdata.name - am I just being silly failing to do this?
Thanks!
You can add a hyperlink like so:
Code:With wbkNew.Sheets("Summary") .Range("A" & NR) = wbkNew.Name .Hyperlinks.Add Anchor:=.Range("A" & NR), Address:=fPath & fName .Range("B" & NR) = Sheets("Cost Summary").Range("A5") .Range("C" & NR) = Sheets("Cost Summary").Range("C7") .Range("D" & NR) = Sheets("Cost Summary").Range("E15") End With
_________________
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!)
Oh great thanks... i was on the right lines and just needed a little tweak!
I apologise to ask another one... I do have a way to do it but it has me fiddling to MSO... subfolders? Is there an easy way to extend the search to them without rewriting for MSO?
This technique will not delve into subfolders.
_________________
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!)
Ah nuts.... thanks, I will have to try and redo it the other way. Thanks and have a good weekend.
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!)
Unless you know what the subfolders will be called.... save me the hassle of a rewrite!
ps. I wasn't the original author so cannot change the thread status I am afraid.
Hijacking someone else's thread wasn't cool, and it against the forum rules. Oh well, the OP appears to have vanished anyway.
Are you asking something else?
_________________
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!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks