I'm building an Excel model using iterative calculations.
The problem results in the yellow cells shown below:
One cell is linked to another and displays a different value than it should.
The bottom value (29.4%) is the correct one, so of course I would like Excel to actually use that one.
When clicking F9 (third picture) one can see that the cell value should technically be correct.
Please let me know if you need any further information as I'm new to SO. Thanks in advance!
Using circular references in Excel requires planning of the layout of the model, in order to get a stable result. And the calculation order is not the same with iterative calculations. One consequence is that if the cell referring to the "iterative cell" is above, it may show the result of the previous iteration.
Here is a very simple model demonstrating that:
A14: 1
A15: =A15 + A14
B13: =A15
B17: =A15
The following shows the results of four single iterations, one at a time. You will see that B13 is displaying the results of the previous iteration; whereas B17 displays the result of the last iteration
If I recall correctly, with iterations, calculations proceed by worksheet in alphabetical order (not sure if that refers to codename or sheetname), and on a worksheet, from left to right and top to bottom.
Related
https://www.dropbox.com/s/zag18z5f13fugn3/Coverlog%20Rota.xlsm?dl=0
Hi
Just need a bit of assistance. Tried a few ways of doing this but can't seem to get it to work.
Below is the Forumlae I used:
Fair enough. Below is my Formulae that I've used.
=INDEX('Cover LOG'!$E$1:$AR$89,MATCH(A3,'Cover LOG'!$C:$C,0),MATCH($B$1,'Cover LOG'!$E$1:$AR$1,0)*2)
It works with the first date, but when it gets to the second date the last four columns give back #REF!.
When it goes to the third date the last six columns this time bring back #XREF!.
I've uploaded the file on the link as this was the only way I could explain it fully.
Essentially when the date changes at the top on the FC Dash I want the relevant columns from Cover LOG to pull through.
Can anyone help?
Jay
The issue is probably that one of the Match functions don't match and therefore the Index function fails. Or that the column/row exceeds the given range in the Index function.
So you need to evaluate your formula step-by-step:
Select the cell that you want to evaluate. Only one cell can be evaluated at a time.
On the Formulas tab, in the Formula Auditing group, click Evaluate Formula.
Click Evaluate to examine the value of the underlined reference. The result of the evaluation is shown in italics.
If the underlined part of the formula is a reference to another formula, click Step In to display the other formula in the Evaluation box. Click Step Out to go back to the previous cell and formula.
Continue until each part of the formula has been evaluated.
More Info: Evaluate a nested formula one step at a time.
With a evaluation you see which part of your function returns which value. So you can easily see which Match function returns a value and which one fails because of no match.
Explanation of your debug result:
=INDEX('CoverLOG'!$e$1:$AR$89,3,68)
The above Index formula means get row 3 and column 68 of range $e$1:$AR$89 in sheet CoverLOG.
If we now analyze the range $e$1:$AR$89 it has 89 rows and 40 columns. You can test this with the following formulas:
=ROWS($E$1:$AR$89) '=89
=COLUMNS($E$1:$AR$89) '=40
but you try to access column 68 which exceeds the range total columns that is only 40 columns.
I've been struggling with this longer than I care to admit, but I have a fairly simple OFFSET function call which works on one sheet, but if I copy it to a different sheet it gives a #VALUE error.
On a sheet named "Deliverable" I have this formula in a cell:
=OFFSET(Deliverable!$B$72,1,0,,3)
and it works fine.
If I go to any other sheet and use the same exact formula, or use it in the Name Manager, it gives a #VALUE error.
If I leave off the final parameter indicated the number of columns I want, it does work:
=OFFSET(Deliverable!$B$72,1,0)
but of course isn't giving me the range I need.
Any idea what's going on with this?
I'm using Excel 2016 on Windows 7.
-- Updated Info --
In a nutshell, my spreadsheet has two cells which I'm using as dropdown lists, where the 2nd cell's list feeds off the selection in the first. The data they are based on has this format:
OptionA A B C D
OptionB A B
OptionC D E F
So the first dropdown uses a simple Data Validation source pointing to the column with OptionA, OptionB, etc. Once that's chosen, the second dropdown list should contain the appropriate options for the one selected. So if OptionB is selected, then the 2nd dropdown list should show A and B.
When I initially wrote this, the data validation source was just a simple VLOOKUP entry, but the lists often had blanks since the number of options varies for each entry. Wanting to fix it up a bit, I ended up with this formula:
=OFFSET(Deliverable!B72,Deliverable!B87,0,1,COUNTA(OFFSET(Deliverable!B72,Deliverable!B87,0,1,5)))
There won't be any more than 5 options, and there are no empty cells in the middle of the data to filter out.
In one spreadsheet I have I used this as a named range definition, then specified the named range for the cells data validation source and it worked. In this other spreadsheet however, it gave me the error described earlier.
However, it looks like when I enter the statement directly into the data validation source field and not in the name manager, it works as expected.
Am I taking the totally wrong approach?
What is it that you want this formula to do? As written, it is returning a block of three horizontal cells. The #VALUE error is Excel's way of telling you "Hey, you're trying to return three cells, but I can't fit them all in the one cell that you are calling this formula from".
The reason you see a result in some places and not others is because of something called Implicit Intersection. Give it a spin on Google. But basically, it just returns whichever one of those three results corresponds to the column that the formula is entered into. If you copy that exact same formula to say row F you will see that it returns a #VALUE error there, because it doesn't know what cell it should return given the column you're calling it from doesn't match any of the cells it is returning. The fact that you don't know this indicates that the formula you're using doesn't in fact do what you think it does.
--UPDATE --
Okay, following your further clarificaiton it seems that you're talking about Cascading Dropdowns aka Dynamic Dropdowns. Lots of info on Google about how to set these up, but you may be interested in an approach I blogged about sometime back that not only provides this functionality, but also ensures that someone can't later on go and change the 'upstream' dropdown without first clearing the 'downstream' one should they want to make a change.
Note that those links talk about a slightly complicated method compared to others, but the method has it's advantages in that it also handles more levels than two, and your DV lists are easily maintained as they live in an Excel Table.
This sounds like an array equation. Try hitting Ctrl+Shift+Enter in the other sheets to validate it as an array equation.
Whenever you need to reference ranges instead of single cells, Excel needs to know that you are working with arrays.
I am making a payroll program in Excel and one of my concerns is that the salaries of the employees are searched using the INDEX and MATCH or VLOOKUP function. The problem is if the salaries get updated in the future (e.g. a raise or changes in rates), all the previous entries that used the old salaries will be updated to the new salaries. This is a disaster and would make my entire program useless and inefficient. Therefore I need to automatically lock previous calculated cells after a certain time.
Edit: Note we do not want to do this manually such as copy pasting values only because almost all cells are connected to each other and one mistake by the encoder or if they forget to do this before updating a value, everything will be messed up.
No! Not copying and pasting, there's a simpler way. You want to convert the Formula property of a given cell (what's shown in the formula bar in Excel) into the Value property of the cell (what's shown in the cell on the spreadsheet). For a given range A1:B6 this would done by the statement
Range("A1:B6").formula = Range("A1:B6").value
But there's a quirk in Excel that you can run faster by accessing a Value2 property, so
Range("A1:B6").formula = Range("A1:B6").value2
The rest of the code is left as an exercise for the reader :-)
how to form an IF function for the following statement:
IF (1 or 2 happens) then IF 1 happens A happens and IF 2 happens B happens?
I think you are talking about nested IF statement
Stick numbers 1, 2, 3 in cells A1, A2, A3, then in Cell B1 stick the below formula and drag it down
=IF(A1=1,"A happens",IF(A1=2,"B happens","Neither A or B"))
And your results
I know this is an old problem but it seems to be left dangling because the OP
did not express himself well.
My answers is for the people whose searches bring themselves here.
The originals posters has a common problem in asking a question about Excel because they don't understand a fundamental point about excel solutions.
A cell formula can only set the value of the cell it is in using information from elsewhere in the sheet.
There is no action at a distance.
The OP idea that something can "happen" is not excel thinking.
The "happening" event has to be laid out as a set of calculations that
each produce a piece for the event. Each piece would then be put in a separate cell controlled by the if statement condition.
For example if the event was "show a schedule for the Day".
The test could be is it a Weekday or a Weekend.
Part of the schedule could be Wake up time, Breakfast Food, Clothes to Wear.
The options for Weekday/Weekend could be for each question 6am/10AM, Cereal/Eggs, and Suit/Jeans respectively.
Each item would be in its own cell displaying its result, this will take up 3 separate cells that will all depend on the day which is stored in yet another cell.
Each of the 3 results cells would have a formula that looks like this (in English not Excel):
For Wake up time:
if(Date in question is a weekday, display in this cell "6AM", otherwise display "10AM")
I do not intend to build an actual sheet out of this because my intent is to
point out how to think in excel.
To summarize: to show a complex conditional result in excel you must show each of it parts in a different cells that all depend on one common cell.
Update: File
Upon request, I am including the link to the file: here. File no longer available
I have transformed my original data into a game-like context, in which the sheet keeps track of points for completed activities and upon reaching various point amounts, the user goes up in rank. An easy way to see the issue is to enter a 1 (and then 2 and 3) into F15 next to the cell with 500. When you do so, notice how the values in Q5:Q6 change from 0 to 1, but Ranking in C2 which is the SUM function which counts this range does not increase to 3 like it should. And consequently the values in L12 and L14 which are based on it also don't update. Now, if you recalculate, the rank goes up and the L cells update. NOW, cell E3 which is based on the L cells doesn't reflect the correct value, and you have to once again recalculate the sheet for it to update.
Hope all that makes sense - let me know if you need any clarification!
Original Question
Some of my formulas are not updating right away after I have entered in data. Just to get this out of the way before someone suggests it, I DO have the calculation of the workbook set to automatic, and I DON'T open any other workbooks with their calculation method set to manual. So that's not the issue.
I would give specifics on formulas, but I don't think it has anything to do with that. The formula is a simple SUM function which adds together a range. The range updates properly - as soon as I've entered data, the numbers in the range change accordingly. The SUM function should likewise automatically update, but I have to enter data in another cell or press delete in an empty cell (basically, get the sheet to recalculate once again) to get the SUM function to reflect the changes in the range.
The only thing that I can think is that it's because I've enabled iterative calculation (in File > Options > Formulas tab) in order to allow cells to retain their previous value if a certain condition is true, else update their value. My settings are 1 for Maximum Iterations and the default of 0.001 for Maximum Change. However, I've used that before without having issues with a simple SUM function. And I have other just as simple functions in my sheet that DO update properly, so I'm a little confused...
Let me know if any more info would be helpful. Thanks for any suggestions!
UPDATE:
Sorry, I didn't catch that this is for a formula, not function. My bad.
I'll leave the answer up in case someone has the same issue, but with a function. Sorry!
Try adding this inside the code:
Application.Volatile
This will force recalculation for the function each time a cell is changed on the sheet in which this function appears.
Reference: http://msdn.microsoft.com/en-us/library/aa213653(v=office.11).aspx
You have circular references: cell formula in range S4:AL103 all refer to themselves (under cetain conditions). This will cause excel to stop calculating because it can't resolve the conflict.
You wll need to redesign your formulas
Originally added to my initial post; moved it to an actual answer so that it could be accepted
So I figured out the solution. From doing a little more reading up on iteration, I discovered that in iterative mode, Excel processes cells one at a time, in a certain order (alphabetical, I think?). So if cell A is dependent on cell B, but cell B changes value later in the process, cell A will retain a value based on cell B's old value, rather than the new one, until another recalculation is prompted... OR, until another iteration starts. So, setting maximum iteration to a higher number than 1 fixes the issue. Since I had two cells not updating in the example sheet I gave you guys, it would need to be set at about 3. In my actual sheet, I had to set it at 5.
Thanks for the thoughts! Hope this helps some other confused soul!