SOLVED

Macros and VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-2984104%22%20slang%3D%22en-US%22%3EMacros%20and%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2984104%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20can%20I%20come%20up%20with%20a%20vba%20code%20to%20run%20the%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2984104%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2984227%22%20slang%3D%22en-US%22%3ERe%3A%20Macros%20and%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2984227%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1145789%22%20target%3D%22_blank%22%3E%40mmtawali%3C%2FA%3E%26nbsp%3BWhy%20VBA%3F%20Use%20a%20pivot%20table%20in%20stead.%20Name%20in%20the%20Row%20Field%2C%20Date%20in%20the%20Column%20field%20and%20Score%20in%20the%20Value%20filed.%20Set%20the%20calculation%20of%20%22Sum%20of%20Score%22%20to%20be%20a%20%22%3CEM%3ERunning%20Total%20in%20Date%3C%2FEM%3E%22.%3C%2FP%3E%3CP%3ESee%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2984320%22%20slang%3D%22en-US%22%3ERe%3A%20Macros%20and%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2984320%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1145789%22%20target%3D%22_blank%22%3E%40mmtawali%3C%2FA%3E%26nbsp%3BSo%20you%20are%20not%20talking%20about%20Scores%20but%20Amounts%20owed%2C%20or%20something%20similar.%20What%20logic%2Fsystem%20sits%20behind%20the%20percentages%3F%20Starting%20with%2010%25%20the%20first%204%20days%2C%20then%20three%20days%20at%2015%25%2C%20and%20then%20down%20to%208%25.%20and%20after%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBetter%20to%20upload%20a%20file%20that%20contains%20data%20that%20truly%20represents%20the%20data%20you%20are%20working%20with%20in%20real%20life.%20Remove%20any%20private%20or%20confidential%20information%2C%20though.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2984421%22%20slang%3D%22en-US%22%3ERe%3A%20Macros%20and%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2984421%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1145789%22%20target%3D%22_blank%22%3E%40mmtawali%3C%2FA%3E%26nbsp%3BThank%20you.%20But%20now%20I%20have%20follow-up%20question.%20What%20is%20it%20that%20you%20had%20in%20mind%20with%20VBA%2C%20to%20begin%20with%3F%20The%20SUMIFS%20formula%20seems%20to%20work%20perfect%20for%20what%20you%20want%20to%20achieve.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

How can I come up with a vba code to run the attached.

8 Replies

@mmtawali Why VBA? Use a pivot table in stead. Name in the Row Field, Date in the Column field and Score in the Value filed. Set the calculation of "Sum of Score" to show value as a "Running Total in Date".

See attached.

Thanks @Riny_van_Eekelen. I would also like to be adding a certain percentage to the running totals as an accumulation (Coumpounding). So the opening values plus a % interest and add that months amount son on and so forth. Apologies for incomplete infor. see attached.

@mmtawali So you are not talking about Scores but Amounts owed, or something similar. What logic/system sits behind the percentages? Starting with 10% the first 4 days, then three days at 15%, and then down to 8%. and after that?

 

Better to upload a file that contains data that truly represents the data you are working with in real life. Remove any private or confidential information, though. 

@Riny_van_Eekelen please see attached. That was a good point, should have provided a complete data and calculations.

@mmtawali Thank you. But now I have follow-up question. What is it that you had in mind with VBA, to begin with? The SUMIFS formula seems to work perfect for what you want to achieve.

Yeah its working, but i have a huge data to run this so am afraid that the excel keeps on jamming due to data size. Beacause it is supposed to do this for about 30k members and 5 years on daily transactions.

Hence looking for the best way on how i can run this type of calculations.
best response confirmed by mmtawali (Occasional Contributor)
Solution

@mmtawali Now I get you. Then PowerQuery could be the tool to help you, though it's not very straight-forward, due to the fact that not every person has a transaction on each day, but you want to accrue the rates on a daily basis on the running totals per person. The attached file contains several queries that ultimately come up with the answers as you included on the summary sheet.

 

Not sure though how this file will perform with 30K names and 5 years of transactions, as you will be looking at a potential of 55 million records to begin with, if I calculated correctly. Or can you split yur data into smaller groups? Perhaps it can be optimized but not by me. Sorry!

@Riny_van_Eekelen, Thanks very much. I will try the power querry route.

You have been helpful.