Solved

Speed up =sumif(A:A,A:A,B:B) ?

Posted on 2013-06-03
5
1,010 Views
Last Modified: 2013-06-03
=sumif(A:A,A:A,B:B)

Very quickly gets very slow.

What ways are there to tell it not to add up one million rows (or whatever)?

Typically the business use involves a very few thousand rows, tops. Usually 1 or 2 thousand only.

Purpose is balances by (accounting) reference.

I plan to make it a named formula, so any array type solutions also welcome.

I am trying to avoid A1:A1000 as a solution.

Anthony
0
Comment
Question by:Anthony Mellor
5 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 39216423
Anthony

You could try using dynamic named ranges that will only include rows with values.

What data do you have in the 3 columns?

By the way, the criteria (3rd argument) is normally a single expression not a range.
0
 
LVL 24

Expert Comment

by:Steve
ID: 39216461
Get your data...
highlight a cell inside it...
then use Data > InsertTable

Then use FormulaNames to name the table.
Then in sumif start typing the table name... it will appear in the list... then open square brackets and a list of your columns will appear.
Construct formula this way =SUMIF(Table1[AA],"A*",Table1[BB])

See attached.

The table will grow / shrink as data in it changes, so the ranges will be the right size automaticaly.
Example.xlsx
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39216543
Normally SUMIF only uses the "used range" anyway so actually using the whole column for the ranges isn't normally any more "expensive" than using a named range.....but why are you using a whole column for the criteria range? If the formula should be copied down then use just

=sumif(A:A,A1,B:B)

in row 1 copied down

Also do you need a sum on each row even if A1 is repeated? You could invoke SUMIF just on the first row for each repeated value, i.e. like

=IF(COUNTIF(A$1:A1,A1)=1,SUMIF(A:A,A1,B:B),"")

regards, barry
0
 
LVL 9

Author Comment

by:Anthony Mellor
ID: 39216875
What data do you have in the 3 columns?

invoice numbers
reference number being cross reference to the payment
amount of invoice(s)
amount of payment

amount of payment contains a sumif to derive the payment from the invoices with the same reference as this payment

amount of balance remaining unpaid per invoice

ok, that's more than 3 columns.
if all Greek I will write and upload an example.

Anthony (I have seen the replies above and now savouring them, thank you).

edit: if an example is needed I will make it another question.

edit I am wondering if the answer is as simple as the twice mentioned criteria needs only be one cell not a column.
0
 
LVL 9

Author Closing Comment

by:Anthony Mellor
ID: 39216962
Points for (if as a mere aside) directly and being the first to solve the problem. The Range as criteria was slowing everything down.

followup re tables Q_28146299.html

follow up re item counts: Q_28146326.html
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
remove dups 10 37
Remove duplicates using cell values VBA 2 32
Alphabetical Order for Letters 2 21
which one of the last argument of YEARFARCis correct to use 5 23
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question