I prepared an Excel worksheet to monitor my trades on Binance crypto market. I created a simple formula to make one cell's value (A12 for example) change to "done" when the coin's value is equal to sell price. (pretty easy). However, this changes when the coin's price becomes less than sell price!
Is there any way to make the word "done" permeant when the condition is met?
Thank you guys.
You could experiment with circular references. Check the "enable iterative calculation" option in the formula tab of the Excel options under the File menu. Then, as proof of concept, in A12 enter the formula:
=IF(A12="done","done",IF(A11>5,"done","undone"))
This will switch to "done" the first time the value exceeds 5 but won't switch back to "undone" if the value later drops below.
On the other hand, circular references make the worksheet harder to reason about. A VBA solution will probably be more robust.
Related
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 :-)
i have 2 cells A1 and B1. A1 is connected to an api data feed so the value is changing practically every second. when its value is >= to B1, how can i hold lets say a value of 1 in cell C1. even if the value in A1 moves above and below B1? i'm trying to hold and store a value of 1 to trigger my worksheet_calculate().
C1 =IF(A1>=B1,1,0)
I would suggest that you use a modular variable to keep your value rather than an excel cell, then this value can update an excel cell(s) of your choosing on a frequency of your choice through conditions within worksheet_change or worksheet_calculate
Keep in mind however that worksheet_change and even more so worksheet_calculate fire quite often you may find this becomes a performance bottleneck if the VBA is not gated to only do payload work when absolutely necessary.
An alternative would be to develop a VSTO Add-In to handle your automation cases.
You might have problems with your api not triggering the worksheet calculate anyway in which case the c1 won't get evaluated.
You also might have issues with your api sending a value > x but your system being too slow to pick up that x.
You might want to see if your API offers a =Max( key , since ) , just Max( keyOftoday )
What you might like to do is record the history of a cell, in which case this article might help you. https://www.quora.com/How-can-I-record-a-current-cell-value-that-is-constantly-changing-on-another-Excel-sheet-at-a-specific-point-in-time
At which point it's just a matter of checking if any cell in your recorded range is > than B1
i have a little problem with final formulas in one of my column. How to start. maybe i will explain what i have a then what i want.
i have an excel worksheet with 3 sheets. i want to record goods and what are these goods made of. first is sheet called Goods where is possible to put number of goods i want to make. In this case i want to make 1x sandwich1 and at the same time 3x sandwich2. i dont want make sandwich3 this time.
Second sheet is Matrix sheet where I record every good and what it is made of. This sheet is basic sheet and all other sheets take list of goods (resp. ingredients) from this sheet. Simply when i want to make sandwich1 i look at matrix and know that i need 1x1pc of egg + 1x5g of cheese. And for 3x sandwiche2 i need 3x10g of sausages.
Final sheet is called Ingredients. It is a list of used ingredients from Matrix sheet (exactly same order) to make these sandwiches. I want to fill formulas into column B which would go through one ingredient ofter ingredient and count needed amount of it. So it would look into matrix in the same row and where there is some number it would multiply with number of items from Goods sheet. The list of goods is also in the same order as in the matrix sheet.
I hope you understand now what i want and will try to help me. I think there will be SUMPRODUCT, SUMIF and maybe INDERECT functions but i am not that skilled in excel
thanks for any suggestions
You can use MMULT function here - it's an "array formula" which you need to enter in a range. You can do that like this:
In Ingredients worksheet enter this formula in B2
=MMULT(Matrix!C2:E4+0;Goods!B2:B4+0)
[I'm assuming you have a European version of Excel where ; is used to separate arguments]
Now select the whole range B2:B4, press F2 key to select formula and hold down CTRL and SHIFT keys and press ENTER. This "array enters" the formula in the range and you should now see curly braces like { and } around the formula and also the correct results.
You cannot change part of that array now, only the whole thing
Note that I'm assuming that the contents of Goods!A2:A4 will be the same as Matrix!C1:E1 and in the same order. You can extend the ranges to be as large as you like as long as that principle still holds
I suspect that this is an issue of "when all you have is a hammer, every problem is a nail". For reasons known only to you you are using a spreadsheet to solve a problem that databases were made to do. Any solution to this problem in a spreadsheet will be entirely dependent on the integrity of your data - add another column or get things out of order and it will fail.
That said, what you have in your link is effectively a pivot table and what you need is the unpivoted version of this - the instructions for getting this are here.
When you have that, you can use the various database functions in excel to get your answer.
I have a specific question concerning the calculation procedure in Excel. Thing is, I have a couple of rather "slow" functions that I have implemented myself in VBA. Everytime I open the specific workbook, or only make a small change in a worksheet, everything have to calculate and thus, take a very long time (annoying).
I wonder if there is a way, other than just checking "manual calculation" under "options/formulas", to control certain (self-implemented) VBA-functions to calculate ONLY on demand (with press of a button for instance)? The most optimal solution would be to be able to have all other formulas to be calculated automatically, and the remaining VBA formulas only calculated when needed.
Thanks,
N
You could have a control cell that links to your VBA functions.
If cell A1 = 1 fire script, else end.
Then when you want it to calculate make it a 1, else a 0?
You could do it with a tick box to make in slightly more elegant. :)
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!