I created a spreadsheet that contains a lot of formulas which use SQL to retrieve data. The spreadsheet is pulling data for manufacturing operations, each row represents an operation. Here are examples of the cell formula:
=IF(B5>0,SQL.REQUEST("DSN=...,"select top 1 customer.csname from orders... where job_number = " & C5),"")
=fnGetOpData("M",B2,B4,B5) <-- Operation Make Ready Time
=fnGetOpData("Q",B2,B4,B5) <-- Quantity to output
=fnGetOpData("R",B2,B4,B5) <-- Calculates Run Time
The 3 columns above require number crunching using VBA via a function - which performs a couple SQL selects. You can see the last 3 are the same function call with a change in the arguments.
Therefore, for each row the same function is executed 3 times - time consuming. (Of course, we have turned off auto calculate and the user performs a manual calculation.)
I would like to revise this to speed up the performance. I realize there's a technique to process each row of a range and store values into cells, but, have not found a resource that explains how to do this in terms that I can understand - there always seems to be an assumption about some aspect already being understood.
My gut feeling for the gist of this is: (1) define the range of cells, (2) create some iteration process, i.e. For i = {row i} thru {row n} ... Next, (3) perform a function (or other routine) that stores the results/calculations into the appropriate cells of the row.
Can anyone direct me to a resource, or, if it's short enough, provide the instructions?
Bookmarks