Total numeric values for any given date

lazzareo

New Member
Joined
Oct 13, 2009
Messages
28
Hi,

I have a basic spreadsheet with 4 columns of data:


  • Column A contains a date
  • Column D contains a numeric value

I want to run a macro/query that outputs the total numeric values for any given date.

e.g.

[TABLE="width: 578"]
<colgroup><col><col span="2"><col></colgroup><tbody>[TR]
[TD]Week Commencing[/TD]
[TD]Name [/TD]
[TD]Location[/TD]
[TD="align: right"]Days[/TD]
[/TR]
[TR]
[TD]02 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]02 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]02 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]02 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]09 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]09 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]09 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]09 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]16 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]16 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]16 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]16 January 2017[/TD]
[TD]anonymous[/TD]
[TD]London[/TD]
[TD="align: right"]4[/TD]
[/TR]
</tbody>[/TABLE]


How could I do this?

Thanks.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi, maybe you could consider a formula:


Excel 2013/2016
ABCDEFG
1Week CommencingNameLocationDaysGiven DayTotal
202 January 2017anonymousLondon409 January 201711
302 January 2017anonymousLondon4
402 January 2017anonymousLondon2
502 January 2017anonymousLondon4
609 January 2017anonymousLondon3
709 January 2017anonymousLondon4
809 January 2017anonymousLondon2
909 January 2017anonymousLondon2
1016 January 2017anonymousLondon5
1116 January 2017anonymousLondon2
1216 January 2017anonymousLondon5
1316 January 2017anonymousLondon4
ALLCOMPS
Cell Formulas
RangeFormula
G2=SUMIFS(D:D,A:A,F2)
 
Upvote 0
Try this for results starting "G1":-
Code:
[COLOR="Navy"]Sub[/COLOR] MG20Nov31
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Dt [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    Dt = CDbl(DateValue(Dn.Value))
    [COLOR="Navy"]If[/COLOR] Not .Exists(Dt) [COLOR="Navy"]Then[/COLOR]
        .Add Dt, Dn.Offset(, 3).Value
    [COLOR="Navy"]Else[/COLOR]
        .Item(Dt) = .Item(Dt) + Dn.Offset(, 3)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
Range("G1").Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .items))
Range("G1").Resize(.Count).NumberFormat = "dd-mmm-yy"
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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