I'm trying to process some data using Microsoft Excel 2010 and have come to something which confuses me. I have one cell which is doing the randbetween() function and is only referencing one other cell.
When I change the value for a completely enrelated cell to either of those cells then it changes the value for those cells which use the randbetween() function.
Why's it doing this and is there a way to stop it doing this?
Volatile functions will recalculate automatically whenever an action takes place in Excel-e.g., entering data somewhere else, or forcing a recalculation of the worksheet by pressing F9.
Some of the volatile functions are
Rand()
RandBetween()
Now()
Today()
To stop volatile calculations from calculating, you will have to change the calculation mode to Manual.
Related
I am wondering if in Excel there is a way to change columns as described below?
=A1*(Formula that returns a letter)2
so for example the formula returns the letter F the result would be
=A1*F2
then if in cell A1 = 3, and F2 = 7. then where the Excel formula is the result would be 21.
I am hoping this approach is possible as I am hoping to use it in a SUMPRODUCT(SUMIFS(.......................................)) where the data I am analyzing is in a mess of columns and labels. and am confused with what else I can try.
The INDIRECT function can take text-that-looks-like-a-cell-reference and convert it into a valid cell reference.
=INDIRECT("A2")
=INDIRECT("A"&2)
=INDIRECT(<formula that returns a letter>&2)
=INDIRECT(<formula that returns a letter>&"2")
... each of these is the the same as,
=A2
All you have to do is pass along some constructed text string that can be interpreted as a cell reference into INDIRECT.
Caution should be exercised when using the INDIRECT function as it is considered a volatile¹ function. If they are used in calculation-intensive formulas or very prolifically, the user will experience calculation lag whenever anything in the workbook changes.
¹ Volatile functions recalculate whenever anything in the entire workbook changes, not just when something that affects their outcome changes. Examples of volatile functions are INDIRECT, OFFSET, TODAY, NOW, RAND and RANDBETWEEN. Some sub-functions of the CELL and INFO worksheet functions will make them volatile as well.
Is it possible to prevent calculations happening to a single cell in Excel sheet? Let's say I have 1001 cells that are very fast to calculate, but 1 cell slows sheet down, is it possible to disable calculations for that 1 cell only?
What I'm NOT trying to do:
Disabling all of cell calculation programically
Calculating specific cells programically while global calculation is set to manual
Use Excel's =IF() function. It is set up to "short-circuit" -- it only evaluates the second parameter if the first parameter is true, oppositely for the third parameter.
So, if the cell is C1, and the cell's formula is currently
=LOOKUP(2,1/(A1:A100000=666),B1:B100000)
and you want it to only be calculated when D1 is true, use
=IF(D1,LOOKUP(2,1/(A1:A100000=666),B1:B100000),C1)
Notice it's a circular reference -- it's how you keep the value the same when D1 is false. Turn on iteration if you want to get rid of the warning message.
Another way is to use one of the third-party Add-Ins out there that lets you store a global variable off-sheet and then retrieve it, which would use syntax like this:
=IF(D1,SetGlobal("C1StoredCalculation",LOOKUP(2,1/(A1:A100000=666),B1:B100000)),GetGlobal("C1StoredCalculation"))
SetGlobal() and GetGlobal() can also be written in VBA, though they'll be a tiny bit slower than an XLL, and they'll lose the value if you reset your VBA project.
Excel does not have a method to disable calculation for a single cell.
You could move the slow formula to a separate sheet and use worksheet.enablecalculation to disable calculation for that sheet.
Or you could store the formula somewhere as text, store the result as a value in the cell, then restore the formula when you want to calculate it.
You can use a replacement UDF and take advantage of a lack of volatility.
Say we have a formula like:
=LOOKUP(2,1/(A1:A100000=666),B1:B100000)
Excel will re-calculate this if any cell in cols A or B change, but the UDF
Public Function myudf(r As Range) As Variant
myudf = Evaluate("LOOKUP(2,1/(A1:A100000=666),B1:B100000)")
End Function
will only be re-calculated when its argument changes. So pick a cell and enter:
=myudf(Z100)
make any changes you want to cells in cols A or B and myudf will remain un-re-calculated until you change Z100
You can use the same tiny trick to make "quasi-volatile" versions of =TODAY() or =NOW() for =RAND()
I don't think this can be done. You can turn off automatic calculation in entire workbooks (as you mentioned), but I don't think there is a way to do this on an individual cell.
I am using the formula to ~300 cells which takes the address dynamically using INDIRECT function, but it is slowing down the calculation time.
please suggest me an alternative method to make the calculation faster.
I have done basics as it has macro with screen updating= false and calculation=xlmanual.
=SUMIFS(Sheet1!$L:$L,Sheet1!$I:$I,Bookings_QTD!$F51,Sheet1!$B:$B,Bookings_QTD!I$2,INDIRECT($I$8),$K$8,Sheet1!$C:$C,$M$8)/1000000
here cell $I$8 is dynamic where values will varies based eg:-Sheet5!$A:$A, Sheet5!$B:$B...
$I$8=Sheet5!$E:$E
I need to use it for many cells ~400+ with other criterias in future.
kindly suugest me better formula or method which will decrease the calculation time.
Thanks in advance
INDIRECT() will be slow for many sheets as it is a Volatile function. i.e. every time there is a change in any cell in the workbook, it will get triggered.
If your cell values are relatively static. i.e. if you are indirectly referring to cell "B6" and you expect the content of B6 to remain the same and only expect the input of your function to change, say from "B6" to "Z8", you can use the following code:
Function MyIndirect(RangeStr as String) as Variant
MyIndirect = ActiveSheet.Range("RangeStr").Value
End Function
This should work. And should you need to 'refresh' this value, simply run an Application.Calculation (i.e. press Ctrl-Alt-F9)
Description of my application in Excel:
I import data to a sheet called RAWDATA
Another already existing sheet Table1 is to be populated by data from cells containing references to RAWDATA.
The reference =RAWDATA!$A$1 is in one of the cells of Table1.
When I run the application, the previously mentioned cell returns #REF!.
I try to update calculations, manipulate with application calculation manual. I still get #REF!.
I click in the formula bar of the #REF! cell. Press enter. It calculates correctely.
What can I do to fix this?
Note that I can only use worksheet functions for the process of getting values to the table, not VBA code.
It is possible to postulate a theory that could explain this behavior. However, I would like to listen to an expert's opinion on this matter.
The issue in brief:
=RAWDATA!$A$1 returns a #REF! error.
#REF! error does not go away with recalculation, but it goes away by:
Using INDIRECT("=RAWDATA!$A$1") instead of =RAWDATA!$A$1.
Clicking on the formula bar of the #REF! cell and pressing enter.
I believe that excel does not recognize the data type that you import from the other application. Therefore, a reference to this data causes the #REF! error.
Can you check if this claim is true?
If it is false, it invalidates whatever is written below.
Excel has a built-in automatic conversion mechanism. For example, if a cell is formatted as text but it looks like a number (say " 10 ") then adding a numeric value to that, is legitimate, because excel internally converts that text to a number.
For some reason, the automatic conversion tool of excel does not work when you recalculate the sheet, but it works when you activate the reference cell and press enter (so when only the cell is recalculated). Also, it is triggered by INDIRECT.
So I tend to believe that the mechanism that infers the cell value type is induced by INDIRECT and by pressing enter in the formula bar, but not by recalculating the sheet.
PS: INDIRECT is a volatile function (it is reevaluated every time that excel recalculates) but since recalculation does not work in the first place, this is probably irrelevant.
I've got an Excel spreadsheet that uses a C# Component.
The component is an Excel Add-in and it's called via a cell's formula function.
ie
=MyCalculation(C24)
The cell C24 has a hard coded value in it, ie text that never changes and isn't based off of a formula.
However, if I instrument my C# code for the MyCalculation I find that it's called 3 different times for each cell that has that formula during the setup.
I've cached the calculation on the C# side but I'd like to know if there anyway to tell Excel that this value never changes and it only needs to look it up once?
I assumed that if its dependencies never change then it wouldn't recalculate the value.
Excel's calculation algorithm is such that it frequently calculates formulae/functions more than once. Usually (but version dependent) after the initial calculation has determined a final calculation sequence the formulae/functions only get recalculated when they are dependent on a cell that has been dirtied (note that setting a cell to "Fred" dirties the cell even if it already contains "Fred") or is volatile.
However there are also more unusual circumstances that cause cells to be recalculated.
There is more information about this at my website.
There is no way of telling Excel never to recalculate a formula, (apart from converting the formula to a constant) except by inhibiting calculation for an entire sheet.