in excel, a formula with no references to other cells changes all cells value when editing one of the cells - excel-formula

if i use a formula like this, which doesn't have any reference to any other cell:
=CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,42949),4),"-",DEC2HEX(RANDBETWEEN(0,4294967295),8),DEC2HEX(RANDBETWEEN(0,42949),4))
and paste it to multiple cells on a sheet, then simple double click a cell and hit enter (no changes), all the cells that have that formula change value.
Anybody know why?

Excel has the concept of 'volatile functions'. These include RAND , NOW, TODAY. Volatiles are recalculated when the book is opened and whenever a cell is edited.

Related

Have a formula as text in one cell and use that text to put in formula in another cell

I need to write a "master" program to read from all (around 30) other excel sheets every single month.
See what I'm talking about
So basically I have a formula as text in one cell called "joined". What should I write in another cell to treat that "joined" cell as formula, that in that new cell it'll execute code and get a cell D3 from other sheet?
You are looking for INDIRECT, something like =INDIRECT(B8) (if I'm interpreting the picture correctly) will get the value in cell D3 in the file and path listed.
But note that these sheets must be open for the function to work. To access "closed" sheets you will need VBA.

Excel bug: Formula moves when referencing other worksheets

Many times when I'm creating formulas (and it seems to happen more often when they are more complex formulas) the location of the formula moves to the sheet I'm referencing. For simplicity, if I'm in A1 on Sheet1 and I type "=" then select Sheet2 and click on M13 such that the formula then reads "=Sheet2!M13, when I hit return, that formula will show up in cell A1 of Sheet2 instead of Sheet1.
I can't seem to figure out what I'm doing in those instances that creates this issue. Any help would be appreciated.
It is possible to create the behavior that you are seeing.
If you happen to hold down the Ctrl key during Sheet selection, then both Sheets 1 & 2 may become Selected (as a group).
If this is the case, then it is possible for the formula to get deposited in cell A1 in both Sheets !

Reference range of text cells from another sheet

I have cells O4: P23 blank in 'Sheet1'. I want the contents of these cells to be populated with the contents from cells B2: C21 (same size range) from 'Sheet2'. If I copy and paste the contents from Sheet2 in to the location I want in Sheet1, it works just like I want, but if I try to use referenced formulas in O4 of Sheet1, I get the #Value! error. I have tried this already:
='Sheet2'!B2:C21
This post has a similar problem, but the solutions listed seem like they are overcomplicated and I feel like it should be much easier than this. I am using Excel 2013 and the worksheet is macro enabled, but I'm hoping to stay away from macros if possible.
In O4 enter the formula
=Sheet2!B2
No $ signs in the cell reference. This is a relative cell reference, i.e. it will change when copied across (to =Sheet2!C2) and down (to =Sheet2!B3). Copy across to P4 and down to row 23.
Note that a cell reference for a range does NOT have a space after the colon, like you wrote in your comment.

Can I use one formula for several sheets?

I have a workbook that currently have 20 sheets and it grows with about 3 sheets per day.
All sheets use the same formulas in columns H-L.
But sometimes I find errors in the formulas or need to ad a condition to it and then I need to update all sheets formulas with the same formula. And that is the problem.
Can I have the formula in one cell somewhere and in each column just reference to this formula so that if I change the formula in this cell it will change in all places?
In each sheet I need the formula to "fill down" about 2300 rows.
In sheet1
A1
=A1+B1
In sheet2
A1
='sheet1'!A1 // will calculate A1+B1
Anyone know of a way to do this?
If all sheets have the same structure, you can use a 3D selection to change a formula in the same cell on all sheets.
For example, if your workbook has sheets 1 to 10, select cell B1 in Sheet1, then hold down the Shift key and click Sheet10. Now all cells B1 in all sheets from Sheet1 to Sheet10 are selected, no matter what the sheet name is.
Enter a formula like =A1+A2 and hit Enter. Click any sheet and check the result. B1 will have that formula in each of the sheets.
Now go back to Sheet1, select B1, hold Shift and click Sheet10. Change the formula to =A1*A2 (multiply instead of add) and hit Enter. Copy the formula down.
Check the other sheets and see that the same formula has been applied and copied down on all other sheets.
With this technique, you can select the same cell in all sheets of the workbook and change the formula in all sheets with just one edit. Of course, it only works if all sheets in the selection have the same data structure.
Edit after comment: You could use the first sheet as the Formula Master sheet, and just need to remember that if you want to change a formula, you first have to use a 3D selection. Other than that, Excel does not offer formula replication in the way you describe. A reference to a cell will always return the cell's value, not its formula.
You could create a UDF (user defined function) in VBA for your goal:
Press Alt+F11, right click on your project in the project explorer and select Insert --> Module. Paste the code below:
Function ExecuteFormula(ByVal Target As Range)
On Error Resume Next
ExecuteFormula = Evaluate(Target.Formula)
End Function
Now you can use the ExecuteFormula() like every other function. If you want to enter the formula in your master sheet as a string "=A1+B1" just replace the 3rd line with:
ExecuteFormula = Evaluate(Target.Value)
I hope this helps.

Need a cell to recognize sheet/tab name in another cell in the same sheet, and pull a value from that sheet

My first post on here. I am looking for help on a problem I have encountered at work. I need a cell to recognize the name of a tab/worksheet from another cell, and pull up a value from that worksheet. FOr example, the sheet's name is 'Destination', I want something that goes to that work sheet and pull up the value in cell C1. The value will be in the same cell in every tab, so in this example, it will always be in C1. Ideally, I'd like a formula as I have never used VBA but if there is no way around it, I'd appreciate a simple VBA code as well.
I would like to copy this formula to multiple cells in the same column, where the name of the tab changes but the cell location does not.
Thanks for your help.
If you want to use a formula, use the INDIRECT formula. As an example, cell A1 contains the word destination. The below formula will pull information from the Destination Worksheet, Cell C1.
=INDIRECT(A1&"!C1")
Let me know if that helps.

Resources