Order in which excel dependent formulas are calculated - vba

I want to understand how the interdependent excel formulas are calculated specially I am interested in the order and process
Simple example
e.g. I have two formulas in excel spreadsheet,
cell A4 contains =SUM(A1:A3)
cell A5 contains =Round(A4)
I am assuming A5 Waits until A4 is calculated and that's somehow tracked and implemented by excel internally.
Is my assumption right?
I wanted to get a better understanding of this "somehow"
May be excel uses some dependency graph , is threading involved? etc. anything that helps me understand!
The motive behind the question is, I have an Excel-Addin from some third-party software and the formulas I used in the sheet makes me suspect that each cell is waiting for other to execute first hence going into a lock state.

Excel builds a dependency tree and walks through it calculating each cell in the order you would expect. However, since there can be circular references it may do multiple passes until nothing changes (or the change is very small). The max passes is controlled by the "Iteration" setting.
In Excel 2007 and greater, there is support for multi-threaded calculation.
For your simple case where there are no circular references, most likely the third-party addin is doing something funky if Excel is freezing. Here is an MSDN article describing the calculation process in detail: http://msdn.microsoft.com/en-us/library/office/bb687891(v=office.15).aspx

Related

Macro recorder or programmed macros, a button expedition

I am not proficient in either macro scripting in excel or scripting in general. I have a general sense of syntax and language formatting so I'm not necessarily going in empty handed with trying to program my owns scripts and I'm leaning this way due to the unique scenario I will be using the spreadsheet.
Essentially I'm wanting to track some data pertaining to slots for a pet project. What I desire is a "start" button that prompts which column I would like my "session" to start in, moves the selected cell to that column and prompts for a starting balance and fills it into the appropriate column; then there are a choice of buttons from which one that pertains to each of my bet options (there are 4) and that will fill in a column net to my balance with the appropriate amount as well as update the balance column to the next row. Lastly I would like to have 6(button) options for certain indicators I would like to track.
All of this I would like to run off of keyboard hotkeys if possible. Ultimately I'm mainly asking for resources since most of the "tutorials" show how to make a button, and some sense of hello world macros, but I'm mainly needing to find page navigation macros, input, take existing data, and append or modify that data with current variables.
-Thank You for any advice or resources and for your guys' time :D
I'm currently trying macro recording but it seems a little but specific to copy pasta situations and not so much the calculation, though small, but redundant that I could optimize with better scripting. I'm also finding that most of the buttons output to a text document outside of libre calc.

Does EPPlus formula calculation support multithreading?

I have a use case for opening large workbooks and needing to calculate all formulas. From what I can tell, using the workbook Calculate function only executes in a single thread. I recognize the complexity with calculation dependencies, but for simple cases (many independent formulas), this means calculation will be much slower than in Excel itself.
Am I missing something here? I couldn't find any other references to this question; the closest match I could find was some enhancements to allow multi-threaded writing of workbooks via the packaging API, but nothing about calculations.

Looking to build a lineup builder for the site draftkings using excel

Why excel? Well excel is what is used to import the player salaries.
Now I need the spreadsheet to do the following.
Create teams within salary cap.
Include/exclude specific player function
Build multiple lineups from a selected list of players within the cap
Can I do all of this with excel? or do I need to know excel vba as well?
Also which parts of excel or if necessary excel vba must I need to know to code such a thing? Also if someone could give me a short summary of the steps needed to hypothetically make such a thing it would be great. Thanks.
I'm posting this as a reply because it is too long for a comment window.
Just because Excel has a grid doesn't mean that it is fit for data storage and data handling, on the contrary.
What you typically want to do is create a transparent structure that guarantees the integrity of your data and that allows dynamic portability when needed one day.
Excel is meant to be a spreadsheet, people forget this all the time or they just avoid the topic: although Excel has a grid, doesn't mean that it is a good fit for reliable data storage. It is not even the least complex way of storing data, depending on the amount of VBA that you need to manage all these data and the gates that you unnecessarily open towards potential bugs.
This is why an RDBMS is what will fit your needs, in this case Access would be a good option as it preserves your data integrity if you get the table structure right and it executes a lot of tasks for you that you should otherwise need to program yourself to protect the integrity of your data.
Although you can perform SQL on spreadsheets too, note that Excel does NOT cover related tables (what you typically seem to need for building your teams and salary limits), so what many Excel programmers will typically do is to create their own code to make this cross-table data storage thing work.
Don't do this if the alternative is available and much more reliable and future-proof.
At first sight, it seems that you won't even need any VBA; I'm not sure of all the things you want to do, but my first impression is that you can manage everything with SQL syntax and stored queries in MS Access. You can import Excel sheets into Access if you get their format right so that should not be a problem.
Once your data is stored there, rest assured that you have made your life a lot easier.

Excel VBA - how to handle many cell references without creating a mess

Suppose you have an Excel workbook and you need to write a macro that takes inputs from many different cell references, and updates values at many different cell references, how do you keep the code neat and maintainable?
It would be helpful to know:
best practices
useful tricks
unavoidable difficulties
necessary trade offs
If there are links to existing guides or discussions that would be helpful too. I haven't been able to find any.
Edit: I found http://www.eusprig.org/best-practice.htm very useful - from the European Spreadsheet Risk Interest Group (EuSPRIG).
It slightly depends om what the macro is going to do, but I use 'calculation' sheets, where I gather together the data I need for the macro, and output the results there.
I tend to do this do in defined ranges.
The result data can then be referenced from elsewhere.
Tricks: One thing I do is to create a visual 'check off' for each piece of input data as it's used. This just enables me to make sure that all the data I thought I was going to use, I have used.
Following Naming criteria is better solution , irrespictve of language.
in_name_range, out_name_range
in_num_range, out_num_range
Check points and adding watch , would surely help.
If you are going for modularity, Take care about updated ranges
(As you can't return more than one value at a time better write ranges in some predefined order in some sheet. This works for me.)

Import Excel Workbook contents into a data table (Visual Basic .NET)

I am trying to perform an operation that might be quite simple really, but since I don't have experience in doing this prior to this point, I may be missing something.
I have an Excel file that needs to be imported into a data table in Visual Basic (.NET 2010). Now, I am trying to import as a data-table, so that I can have the data flexible and ready to be used as and how I wanted to.
The Excel spreadsheet doesn't exactly have the most promising and worthwhile formatting, which makes this situation a tad-bit difficult. The column headers are not on the first row itself, but are on the 5th row and this might not always be the case. The column headers might even end up on the 10th row or even the first row - Any help on this would be great too.
The name of the worksheet can also be different, since I don't have any control over the end users that will be using the application. Any suggestions or code-help here please?
You will need to deal with the formatting issues to have true success. A consistent input is the only way to secure consistent output. Otherwise, you will need to build an interface that allows your users to map fields as they go.
Once you have that taken care of, I suggest using the OpenXML SDK to import your values ( http://msdn.microsoft.com/en-us/library/office/hh298534.aspx )