Selective addition

buffalo

Board Regular
Joined
Jun 19, 2003
Messages
183
Hi,

I have two columns, one with dates and the other with scores.
For each date there are many scores...

Every day I keep adding new scroes for that date. At the end of the day I run a macro --

THis outputs the sum of the scores for today's date on to another sheet.

How would I do that using a worksheet type function?

Thanks,
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi b,

How about SumIf?
Book2
ABCDE
1DateScoreDateTotal
229-Jan130-Jan8
329-Jan3
430-Jan5
530-Jan2
630-Jan1
731-Jan2
Sheet1



HTH
 
Upvote 0
Hi works great... actually here is the real problem:
I have TWO columns Date and State, and a third with scores
For each date and state I have many scores.

Now I want to know the sum of scores of every state for today. How would I extend the above?

thanks!
 
Upvote 0
Hi b,

Try SumProduct instead:
Book2
ABCDEFG
1DateStateScoreDateStateTotal
229-JanA130-JanC6
329-JanB3
430-JanC5
530-JanA2
630-JanC1
731-JanB2
Sheet1



HTH
 
Upvote 0
Hi I successfulyy used the sumproduct command but I have 10 'states' and
its somehow running very slowly when I do .formula = "=Sumproduct etc.." in VBA

Guess It takes sometime to write down the whole formula in the cell and then calculate it -- its REALLY slow.

ANy suggestions on how I could speed it up in VBA?
 
Upvote 0
a) define the ranges under consideration
b) post the code you're using
c) explain why you need the vba
 
Upvote 0
Here's the code tothe actual problem

The only problem is its VERY slow...THe code is pretty repetitive. Bogs down everything for some reason.

In the Trade Ticket Data file... I have Date in Col C, Commission in Col N
and Account in Col I.

The names of the account are in Row 2 of the Commissions Sheet. SO for every account we have the Commissions.

I need to use it as a macro. So at the end of the the macro seeks information from the Data sheet and puts the SUM on the Commission sheet, by date and decomposed by Account.
The list grows everytime and only anytime the user executes the macro.


Then instead of Commissions there are other 'scores' and we do the same for thme and this is really slow

(If you would want to look at the actual file -- that'd be great, I could upload it on my web-site)

THanks


Here --> the first column will give today's date..
The next 10 columns will have 10 commission score sums, decomposed by accounts for that day.
Code:
Sub Update()

Sheets("Settings").Range("B33").Value = Sheets("Trade Ticket Data").Range("C65536").End(xlUp).Value
--> This stores the date in Settings!B33

'for Commissions
Sheets("Commissions").Range("A65536").End(xlUp).Offset(1, 0).Value = Sheets("Settings").Range("B33").Value

--> THis gives the date in the first non-emty cell of the first column

Sheets("Commissions").Range("A65536").End(xlUp).Offset(0, 1).Formula = "=SUMPRODUCT((('Trade Ticket Data'!C2:C65536)=Settings!B33)*(('Trade Ticket Data'!I2:I65536)=Commissions!B2)*('Trade Ticket Data'!N2:N65536))"
.. gives Commission for Account which is denoted by in Commissions!B2.

and so on.. for 9 other accounts.


End Sub
 
Upvote 0
you are trying to run the sumproduct formula for nearly every row in the worksheet (65000 times!) try determining the extent fo the range you have actually used on each sheet similar to the method you used to pick the last row of data in column A, use a simiar method and assign that row to a variable, then use that variable in your formula

e.g. "C35:C" & iRowValue

produces the text C35:C25000 if iRowValue = 25000

this will help eliminate unecessary calculation time for XL.
 
Upvote 0

Forum statistics

Threads
1,203,734
Messages
6,057,059
Members
444,902
Latest member
ExerciseInFutility

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top