This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
A massive Excel spreadsheet (60 tabs, ranging to 1,000 x 68 cells each), that I've created to analyze traffic pricing in New York City, crashes when I input values outside of a narrow range in one particular cell. By "crashing" I mean that a huge number of cells -- probably tens of thousands -- return "#NUM!" simultaneously.
As you've guessed, the spreadsheet is recursive in that there are hundreds (thousands?) of instances in which data are passed back and forth among different cells ... as must occur in processing travel choice (e.g., raising road tolls reduces auto trips, but the resulting improvement in traffic flow attracts auto trips, which then worsens traffic flow ...).
Is there a way in which I can "slow down" the calculations in order to see where the #NUM! results first appears? Lacking that, I've spent a good deal of time fruitlessly trying to track down the formula or algorithm that causes the initial #NUM! result, which then infects all of the others, rendering diagnosis impossible.
The spreadsheet, approximately 4 MB, may be downloaded via this link: http://www.nnyn.org/kheelplan/BTA_1.1.xls. The cell that leads to the collapsing values is F444 in the "Taxis" worksheet. Its current (saved) value is unity (1.0). Raising it to 4.0 or even some lesser values will make the spreadsheet collapse ... from which it cannot be rebuilt.
I should say that I'm a mathematician and not at all a programmer. Indeed, I'm more of a "numbers savant" than a mathematician.
Thanks in advance. I'm new to this site and am impressed with it.
In Excel 2010 (but maybe after 2007 all has this function) there is an Evaulate formula button at the Formula Auditing group on the Formula tab.
You select an #NUM! field, and use it on, you can go in to the formula, and Evaluate the formula (calculate a segment of an formula). Also, you have in that group a few helper function, like trace dependents/precedents.
EDIT1:
Oh, and you get this error (#NUM!) if:
You calculated somewhere too big number ~ 1E+308 or bigger in a field
You want to do something like this: 0^0
You get somewhere (in one previous field) this error #NUM! which you want to use
EDIT2:
Now, I found your problem (maybe), you want somewhere to calculate too big number with itaration. If you set Maximum Itarations to 1 it hasn't got #NUM! errors. (you can find this at Excel options - Formulas tab)
Related
I think this problem, when solved by creating additional charts with offsets, is easy. I want to cut out the middle man and not use offsets (unless they are useful to the answer). I have data for daily cohorts and I know specific information about their behavior 1 day later, 2 days, 3 days ect.
Now it is rather easy to make a waterfall chart of day by day activity like so...
What I want to do is skip this step (directly above, the waterfall chart) in hopes of shrinking my current workbook by a substantial amount. You can imagine having simply 1 year of data across multiple channels measuring even 1 aspect of behaviors can account for a lot of data and pivot charts. Also, btw, I have the top chart as a pivot thus allowing this to be hands off when calculating what I am looking for.
What I seek - I look to further construct groups of days as other cohorts to examine (for example, say, 1/1 - 1/5) and see what their activity has been in a cumulative fashion since then. To be more specific, I want a table that will show cohort 1/1-1/5's activity in the date range 1/1-1/5 (11) and then their activity from 1/1-1/9 (24, an additional 13 "behavior points" summed).
So far, as I said, my current solution involves the "blue arrow" schematic where an additional table is constructed and I can sum on, essentially, rectangles build by using OFFSET on sell ranges with the MATCH function. I am stumped with how to go about this without the additional charts.
Thanks!
VBA would better for this, but use this formula in C30:
=IFERROR(SUM(SUMIF(OFFSET(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(C$28)),SEQUENCE($B30-$A30+1),IF(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(C$28)))-SEQUENCE($B30-$A30+1,,0)>COLUMN($B$1),0-SEQUENCE($B30-$A30+1,,0),COLUMN($B$1)-COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(C$28)))+1),1,IF(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(C$28)))-SEQUENCE($B30-$A30+1,,0)<=COLUMN($B$1),(C$29-C$28+1)-SEQUENCE($B30-$A30+1,,-(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(C$28)))-COLUMN($B$1)-1)),C$29-C$28+1)),"<>")),0)
and this in D30:
=C30+SUM(SUMIF(OFFSET(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(D$28)),SEQUENCE($B30-$A30+1),IF(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(D$28)))-SEQUENCE($B30-$A30+1,,0)>COLUMN($B$1),0-SEQUENCE($B30-$A30+1,,0),COLUMN($B$1)-COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(D$28)))+1),1,IF(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(D$28)))-SEQUENCE($B30-$A30+1,,0)<=COLUMN($B$1),(D$29-D$28+1)-SEQUENCE($B30-$A30+1,,-(COLUMN(OFFSET($B$1,$A30-MIN($B$2:$B$10),MIN($B$2:$B$10)-$A30+DAY(D$28)))-COLUMN($B$1)-1)),D$29-D$28+1)),"<>"))
And copy both down.
If one does not have the dynamic Array formula SEQUENCE() then replace all the SEQUENCE($B30-$A30+1) and SEQUENCE($B30-$A30+1,,0) with ROW($ZZ$1:INDEX($ZZ:$ZZ,$B30-$A30+1)) and (ROW($ZZ$1:INDEX($ZZ:$ZZ,$B30-$A30+1))-1) Respectively, and use Ctrl-Shift-Enter instead of Enter when exiting edit mode.
I was able to collaborate on a solution. I am told that it will be highly inefficient at scale but it gets the job done. It ss less automation-friendly but can be formulated to capture data not currently present on a, say, a pivot table that you call to update later by extending the area that the formula works on.
Formula in in I31:
=SUM(IF(($C$1:$O$1+OFFSET($B$2,$G31-$B$2,0):OFFSET($B$2,$H31-$B$2,0))>=I$29,OFFSET($C$2,$G31-$B$2,0):OFFSET($O$2,$H31-$B$2,0)))-SUM(IF(($C$1:$O$1+OFFSET($B$2,$G31-$B$2,0):OFFSET($B$2,$H31-$B$2,0))>I$30,OFFSET($C$2,$G31-$B$2,0):OFFSET($O$2,$H31-$B$2,0)))
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Or perhaps another way to look at it would be how to make a formula result static...
The problem: I have created an invoicing/booking solution for my business using excel sheets, I have many sheets such as delivery addresses, client data and addresses, bookings, jobs, invoices and so on. There are many many formulas which do different things at different times, for example, if a client books a service for an address the sheet will auto calculate the cost of the service through a series of formulas and IF statements. But if I change any of the data a pricing formula relies on it will recalculate all formulas relating to that data change, an example a customer books today at $100, on their next booking I give that customer a permanent discount of $25 on all future bookings, once I add the discount against the customer, the pricing formulas recalculate all the formulas which could cause obvious accounting issues.
I know wrapping time and date stamps in an if statement can stop a similar issue occuring and that their is also macros that can be written to time stamp on an event, can anything be done with the formulas or is there another workaround to this issue, ive almost got all the functionality I need without using any macros which in itself is an achievement but on the other hand if a macro is the only way, any options it would be great.
In short can anyone offer any solutions to making formula results static to those cells, ie rewrite the formula with the result itself so the result is permanent and therefor only editable manually.
I havent included any screenshots as I couldnt really see what would be relevant, but if there are any bits you'd like to see or have more info on to help answer feel free to ask
It's hard to give you specific advise to implement a non-trivial change on a complex workbook-based pricing application that we have no knowledge of. But here goes...
Make up a new table called CustomerDiscount. That table should have three columns: CustomerID, Date, and Discount. Then rewrite your formulas in your 'transactional' sheet where you are taking booking or whatever, so that they match the CustomerID and Date against the CustomerDiscount table and so pull out the relevant discount that applies after date x.
You can likely find generic examples on Google. The concepts involved here are 'Approximate VLOOKUP' or 'Approximate INDEX/MATCH' so try those search terms in google, and perhaps add something like 'look up next highest date' or similar. I can't give you any more specific advice than that without you having a go at implementing this new 'CustomerDiscount' structure, having a crack at it yourself, and then posting back a much more specific question if you get stuck.
Relying on some trigger to either calculate or not calculate a result is NOT the way to go, because you will always have a nagging fear that something might have been recalculated when it shouldn't have been, and vice versa. You need a audit trail. Without one, you're a sitting duck.
There are 2 potential solutions: 1. You can go to your formula tab, to the calculation section, and select to "manual calculation" on/off. It's default is on. But if you turn it off, you can change anything and keep the values you have. However, you will have to hit "calculate now" every time you make a change and need it updated, this is very easy to forget to do.
Secondly, you can right click on any of the work book tabs at the bottom and select "Move or copy", and you can make a copy to a blank workbook. You can then save that workbook as their invoice/book.
Also, you can copy a cell, or range of cells, then right click and "paste values" in which the formulas are replaced with the values you are currently seeing. You wouldn't want to do this on your master workbook.
Contact me if you think a macro automating this would be useful. Hopefully some or all of these ideas are useful to you! Please leave a comment if you need further explanation.
It's my first time posting a question to this forum. Though I have found answers here many times before, I have been unable to find a solution to my current predicament.
I work in a call center and each week I need to analyze data from the thousands of call that took place over the week. I'm new to programming in Excel-VBA but I've been able to get pretty far.
The data is produced by a third party program and the format is nigh unreadable. Much of the programming I've done so far has been geared towards making the data more organized. Now, I'd like to get into more analysis.
The data is arranged by employee number (NOT in order, though). Each employee takes several calls over the course of the week, some for which the customer takes a survey. It's the survey scores I want. I want to take the average of all the surveys for each employee and then display that average in the same row as each of the entries.
Example
The yellow highlighted area is what I want to add. Any ideas? Thanks for any help in advance!
No need for VBA. If you have the supported version of Excel you can use AVERAGEIF. If not you can use below formula.
Enter as an array formula by pressing Ctrl+Shift+Enter when exiting cell edit mode (instead of just enter).
=AVERAGE(IF($A$2:$A$13=A2,$B$2:$B$13))
Then copy down for all rows.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm analysing large amounts of historical financial data using the QuantlibXl library in Excel 2010, 32-bit. My typical worksheet contains long columns of empirical data of up to 1 million rows. My macros usually need to to run through each row from the top to the bottom and do some Quantlib-typical financial analysis stuff like revaluing a security, which requires that Quantlib objects be created in every row. The analytical stuff is contained within the cells as formulas.
So in the beginning I tried to just select the cells with formulas in the top row and fill them down by dragging the lower right corner to the bottom of the sheet. Already here, the processing time grew exponentially with the number of rows involved.
So I figured I had to write a macro that processes smaller chunks of rows at one time. The macro would basically take care of filling down the top row only 100 rows at a time. That and a number of optimizations (explained below) certainly improved speed tremendously, but processing time still grew exponentially.
The problem is that as much as I try to optimize my macros, they keep getting slower and slower the longer they run. I keep track of processed rows in the status bar, and for example if 2000 rows are processed per minute (the calculations are pretty involved) when kick-starting the macro, its speed decreases constantly throughout its runtime, for example to only 100 rows per minute after 60,000 rows. At that rhythm, it will never see the end of the sheet. So in fact, at some point it becomes optimal to just abort it and start it off again from where it stopped. I also splitted the files and let them run on different computers simultaneouesly, which is a pain in the ass in terms of managing.
I already implemented tons of optimizations:
- screen updating and automatic calculations are turned off.
- I only perform calculation on the row being processed at a time.
- garbage collecting: Quantlib objects are deleted immediately after they are no longer used. I thought it was them eating all free memory that caused the slow-downs.
- I got so far to write the relevant results (cells) to a text file and delete the rows that were no longer needed. Again, the macro was very fast in the beginning and would have run until the end within a couple of hours if it wasn't getting slower again after like 70,000 rows. In fact, I had hoped to see a speed increase during runtime as rows are getting deleted and the sheet shrinks, but it just doesn't happen. So I just keep halting the process ever 60,000 rows and kick-starting it again, but its tiresome.
I'd like to figure out what causes this behaviour of Excel not processing large amounts of data linearly and requiring restarts, and how to avoid it. If somebody ran into similar trouble and found a way around it, I'd be glad to hear about it.
EDIT: Every time I halt the process to speed it up again by starting over, I noticed that I have to restart Excel, otherwise it resumes just as slow as before. My current hypothesis is that at some point data isn't cleaned up correctly. If this is the case, your solution would bring me any further. The Quantlib library has a method to look at how many objects still reside in memory called ohRepositoryObjectCount(). I call the ohRepositoryDeleteAllObjects() function after every calculation and they are being effectively deleted as per that other method, but maybe there is still some leakage that remains undetected.
EDIT2: I'm now convinced there is memory leakage as after a long batch the task manager shows 3 or 4 Excel processes consuming together about 1.5 GB of memory. When quitting Excel, it crashes (with a message along the lines of "Excel is not working anymore"), and the processes persist, so I have to kill them manually.
If my assumption is correct, your rows are a listing of all your securities; and are not related to one another; and you don't calculate across them. If that is correct, do the following:
On a separate sheet, layout all your data columns (both input and
output) to represent one row.
Copy and paste values one row of data from your "source" sheet.
Remove all your calculations from your source sheet and put it in here.
Copy and paste values back to your source sheet.
Put #2 to #4 into the macro and loop through your data.
That's my answer, the following are just commentary. If I were doing it:
my "source" data will be in a database. I'm sure there are relations
among the securities that I would to explore.
I would transpose the row elements into a column on my calc sheet for easy reading.
I would break out the calculations across multiple columns and sections for easy reading.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here's one for Joel...
I am looking for ways to demonstrate to an Excel user (with no programming experience) how learning some Excel VBA can make their life working with Excel a little easier.
First thoughts are to use an example that replicates manual tweaking of a spreadsheet, such as one click conditional formatting of all the data. For example: highlighting all the numbers red, orange or green according to user input thresholds coupled with some other derived data such as current business week.
I am hoping that such a short VBA example should not be too difficult to grasp for someone who has never written a line of code before, and hopefully make a case for trying to learn a bit of Excel VBA.
However, with this example the time taken to code it is not significantly quicker than applying the conditional formatting manually in Excel. So I would be interested to know if anyone in the community has any more elegant examples that demonstrate the advantages of using Excel VBA.
Ideal examples would have the following characteristics:
Significant time savings (large T, where T = time for manual procedure / time to code).
Non-abstract, everyday spreadsheet examples.
End results that can not be easily achieved manually.
Achievable with short, basic VBA code.
Bear in mind that the target audience is taking their first steps into programming.
If you can, watch them use Excel for a 1/2 hour and you'll find the perfect opportunity. When they open that one spreadsheet, autofit all the columns, format col A as a date, right justify col J, delete rows 2 through 5, and change the print orientation to landscape then you've found a winner. Have them do it again, but with the macro recorder on. Then replay the macro recorder.
By working with something they use in real life, it will have more impact.
You don't have to save them 1/2 hour a day with the first shot. Save them 30 seconds of drudgery on something they'll use and they'll start thinking of all the things they want automated. In my experience, they'll go overboard rather quickly. In no time, they'll want Excel to go fill out a web form, import the information, and get them a coffee.
Create your own "function" with VBA that you can use like another function from within the sheet.
You can do things that are not possible in plain Excel, or very hard to implement or reuse.
An example:
In VBA create a new module, add code like this:
Public Function SizeOfFile(a As String)
SizeOfFile = VBA.FileLen(a)
End Function
And you can now use SizeOfFile in a formula in a cell.
If cell A1 contains the name of a file, B1 fill with =SizeOfFile(A1) to get the size.
Also
You can show recording (and editing) a macro, to repeat steps that you do often.
Are the people in the target audience power users?
If so, how about combining data from multiple workbooks using external references? I'm not sure if external references are the best way to do this, and I'm not sure how difficult this would be for someone new to VBA, but that's what I ended up doing in the past.
Example 1
There are many excel files following a naming convention:
c:\data1.xls
c:\data2.xls
c:\data3.xls
I wanted to be able to enter the ID numbers in one column and have a VBA to get the data for me for all the other columns. I chose to do this with external references because then I didn't need to worry about opening and closing files and worrying about whether or not those files existed.
I wanted the result to look like this:
id data hyperlink
1 extRefA1 c:\data1.xls
3 extRefA1 c:\data3.xls
500 extRefA1 c:\data500.xls
I didn't need VBA to make the hyperlink, but I couldn't find an easy way to make external references without VBA. I tried using INDIRECT, but the referenced workbook had to be opened for INDIRECT to work. So, I used VBA to create the external references.
Example 2
This one is similar to Example 1, but I had to combine different chart data.
The data in each excel file were in columns:
X Y
1 5
2 10
3 5
4 60
I wanted the combined chart data in rows:
1 2 3 4
data1 5 10 5 60
data3 30 60 4 2
data500 25 45 20 5
So I made a VBA that put a formula array containing an external reference in a TRANSPOSE.
The data1 formula array looked something like this:
=TRANSPOSE('c:\[data1.xls]Sheet1'!$B$2:$B$5)
I don't know how others use Excel and VBA, but these proved to be extremely useful to me.
Francis
My first tentative steps into VBA were taken after I joined a company and saw one of my new team spending 30 minutes each morning compiling a report from a list of about 1,000 items that needed auto-filtered in different ways to produce the required counts. A few hours mucking about with VBA had the task down to a button click and about a second.
Anything like this that involves a loop is going to satisfy your first criteria of a significant time saving. Perhaps a task that involves extracting the area codes or house numbers from a list of 200 phone numbers or addresses?
Here is an awesome msdn link for this question.
http://msdn.microsoft.com/en-us/library/aa203714(office.11).aspx
has everything you need for a short preso.