I've got a collection of about 40 Excel worksheets. They store information about the number of hours that people have spent working on different projects, with dates across the top row from left to right and project names down the first column. Each member of the team has their own separate worksheet.
I'm making a new worksheet that will add up the number of hours each person has spent on a specific project.
I'm using this formula to add up all the numbers in a particular range of a linked file:
SUM(INDEX('S:\path\to\folder[Username_2017.xlsx]Daily'!G:JG,JOB_ROW,0))
JOB_ROW is the row containing the numbers I want to add up. Columns G:JG cover 1 Jan - 31 Dec. Username_2017.xlsx is different for each of the 40 people.
The problem is that the formula only works if I create it by hand. I can't find any way to use a dynamic reference to the filename, which gets very tedious with 40+ files to reference. I thought this might work:
SUM(INDEX(INDIRECT(C3),JOB_ROW,0))
...where C3, C4, C5 etc. would contain automatically-generated filenames and references. But it doesn't work. I get #REF!. And Excel doesn't prompt me to link the files -- which suggests to me that it will never work this way.
I've also found that even when the spreadsheet is working properly with the manually-entered formulae, if I save it and re-open it then Excel tries to be helpful by stripping out the formulas and replacing them with the text #REF!.
Is it possible to do what I'm trying to do? Or do I need to learn some VBA?
I should point out that I've largely avoided using Excel in my career so far -- so if there's a better way to achieve this then I'd love to hear it.
Thanks in advance for your help.
ian0411 gave the simple answer to this question in the comments above: the answer is "you can't do that".
If he wants to post that then I'll accept it as an answer -- but for the benefit of anyone else reading this question and looking for alternative options, here's what I tried and what worked:
VBA
I wrote some very simple VBA using GetObject() to open and read from each of the workbooks. It worked, but a) it was very slow, and b) it seemed to keep all the files open as long as Excel was running, which caused other problems. It also crashed a lot.
I gave up on VBA.
Automating the filename replacement
The next option I tried was to have a column of filenames in Excel, with a column next to it containing the formula that I wanted to run on each file. Instead of putting the linked filename in the formula, I put a unique placeholder ('XXXXX' or whatever).
Then I made a little macro that (for the currently selected row) did a search and replace across the row to change 'XXXXX' to the filename in column A. I had to run the macro 40 times to cover each file, but I only had to do that process once. When I add a new file to the list, I'll just add a new line, copy the formulas, and update the filename.
I've now got a spreadsheet which works perfectly when the linked files are closed, and which doesn't rely on VBA.
Perhaps if my VBA skills were better I could have written something less flaky -- but doing it all with INDEX() seems like the fastest, most elegant, and most reliable solution.
Related
I have an Excel file on SharePoint.
Multiple people edit said file.
Offline and online.
Excel unfills all calculated cells (VLOOKUP and MATCH) that depend on other sheets in the same workbook at random.
So if you would open or reload that file, suddenly all the cells that use VLOOKUP or MATCH would be blank.
Upon further investigation nobody changed anything or deleted anything.
It just happens randomly.
Now it has happened 2 weeks ago and just today.
I have an interim solution that is to go to a cell with a formula, hit return, then click „overwrite all cells in this column with this formula“ and then click undo to prevent custom cell content to be overwritten.
Everything is back to normal afterwards.
I talked to a colleague, he has the exact same issue also totally at random.
He also encountered this on files that are not being edited by multiple people but himself.
So it is not dependent on the file itself.
Could the language play into this problem?
On some PCs Excel is in English and on some in German.
=IFERROR(IF(ISNA(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE)),(VLOOKUP(D185,'Sheet2'!$B$3:$D$22200,3,FALSE)),(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE))),"")
Seems like your sheet isn't calculating upon open. See if this link is of use to you.
https://superuser.com/questions/448376/what-is-the-excel-hotkey-to-re-calculate-all-formula-in-sheet
Also check your program settings and see if auto-calculate sheets is enabled. Don't know from the top of my head where it is located.
Alternative create a small vba function to force recalculate on workbook open.
Getting Excel to refresh data on sheet from within VBA
I want to reference an external workbook that is open. If I type =path\[file] directly into the cell (even though I am still asked to 'Update Values',) I am able to get the data I require. However, I am using INDIRECT because the name of the file changes everyday (date). So, I am using CONCATENATE to create a filename daily and then using INDIRECT to the cell where the concatenated formulas is. If you paste values to see what is being generated formula, it is exactly the same formula as above, =path\[file]. However, I continue to only get #REF! error.
I read through this, https://support.office.com/en-us/article/control-when-external-references-links-are-updated-87861952-ca9d-4d2a-a986-4d672c908d0d, and I still can not figure it out. I had it working on my computer at home last night but today and work it is giving me trouble.
To clarify, the formula that I am trying to get to work looks like this =INDIRECT("'"&CONCATENATE($F$129,$F$130,F95)) which worked yesterday at home. Can someone lead me in the right direction?
EDIT:
I have tried two options, =INDIRECT(F121) and =INDIRECT("'"&F121). The contents of F121 have been =CONCATENATE("'",F191,F192,F157) and =CONCATENATE(F191,F192,F157), respectively. I have also tried =CONCATENATE("'",F191,F192,F157) in the destination cell. F191 = [Liquidity Risk Dashboard v2.03 -, F192 = =TEXT(E3,"yyyymmdd")&"]", and F157 = Calculations'!D122. If I write ='[BMI Liquidity Risk Dashboard v2.03 - 20170105]Calculations'!D122 am asked to update values but, 100% have both workbooks upon in same instance
If I understand what you really have in your cells, the problem is that you are not properly naming the source workbook.
Try changing
F192: =TEXT(E3,"yyyymmdd")&".xlsb]"
Replace .xlsb with whatever the file extension really is for your file. (eg: .xlsx, .xlsm, .xls)
I have a 60mb excel file that has all of the "sins"... Array formulas, VBA and conditional formats. It crashes all the time and it's now being suggested that it's too big. There are about 20 worksheets and 3 of them are 15mb in size and each have about 35,000,000 active cells. Is this why the sheet crashes?
Yea I have this problem also.
This is a compilation of hat works for me. Some of this may be relevant, some may not.
Turn off automatic calculation. If you are desperate about this, then turn it off while doing the rest of the list but turn on afterwards
Make a backup. Everytime something on this list works, make a new backup. Excel has no brain, make sure to use your own.
Remove empty-but-not-empty cells... Sometimes, for a number of reasons, excel finds it necessary to keep track of all possible rows and columns.
I fix this by recreating whatever chart I have made by copying the specific areas that are needed on new sheets and then delete the old one and rename the new one to match. Search/replace will fix formulas afterwards if they get buggered. You can also mark the rows/cols and right-click -> delete rows/cols but that may cause a total freeze so I prefer the former method.
Get rid of the array formulas. Seriously, they can in 90-something % of the time be replaced by a cleverer sumproduct, sumifs or index(match()) formula or by adding columns or doing things in 2 steps. They are resource hogs. Leftovers from a different age. The only time I accept arrays is when I know I have exhausted all possibilities.
Very important, save the files as x64 binary formats for the files (.xlsb). Do not use the "compatibility" format (.xlsx) and for the love of god, do not use regular .xls
Move all graphics to separate sheets, and better yet, separate files. Mirror the result data via vba, copy paste, whatever to separate files and have your conditional formatting, images, graphs, progress bars, gantts, whatever there.
I hope it's not inappropriate to post this.
After some stalling and perhaps some skepticism, I replaced all of the array formulas in my sheet. There were approximately 1,500,000 cells affected by array formulas and I didn't relish the thought of redoing this. BUT WHAT AN UNBELIEVABLE DIFFERENCE! The sheet now runs faster, better and very reliably! I'll never use an array formula again. Thank you!!
i have a folder with .xls files which are all named like xxx_day_month_year.xls and i want to look up for some values in this files by selected date.
I came to next solution:
=VLOOKUP(B3;INDIRECT("'G:\xxxxxxx..\"&G3&"."&G4&".2014_test.xls]HL'!$C:$D");2;FALSE)
Where cells G3 and G4 are desired day and month.
But this only works if I have opened documents in which I look up for data. Is there a way that this formula is going to work in independent document?
I did a bit of digging on my own, and it looks like the INDIRECT function will not work with a closed workbook. However, you could use VBA to accomplish your task.
Take a look at this previous post which explains a VBA workaround for a similar issue. You may be able to adapt it to your specific situation.
I have an Excel document which makes a lot of calculations and shows the results in specific fields as text. I need to get these answers into PHP but Excel Reader can't read those fields, since they are the results of calculations.
So, I want to save the Excel document without the formulas/calculations, but with the results as text. How do i do this?
I'm stuck using Excel 2004 Mac btw.
edit: I forgot to mention: a client of mine has to upload a new version of this Excel document each day (the calculations change daily), so the simpler the solution the better. Also, there are too many values to change them all manually.
A finger dance worth remembering
ALT + E, S, V
To Paste Special (Values)
select all, then copy, then paste special as value
if this is need every day then you almost certainly want to record a macro that loops over very worksheet in the work book and does this