VBA help - Excel table

GeorgeTimes

New Member
Joined
Jul 22, 2022
Messages
16
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
Platform
  1. Windows
Hi all,

I need your help with a table I'm trying to build and need to run it every Monday. I think this can be achieved with VBA.

What I need to do:
- At the beginning of every month, the table needs to erase the details (or simply don't take in consideration the values as I only care about the current month)
- I also need to run the report every Monday, therefore I need to store somewhere the figures as those need to be present in the table for the current month
- I need to find the top 3 countries that have the highest debt at the beginning of the Month(This will be taken from the tab called "Source Data". Think this can be done by a Pivot table where I'll look for the SUM of column L "Total 90+ EUR"
- From those 3 top countries, I need to extract the top 5 companies for each country (Not sure how this can be done). However there might be exceptions so this leads to the below:
- Assuming running this on first Monday of the month (02/01/2023), I get the top 5 companies for each top 3 countries.
Next Monday (09/01) I'll run this again and I get the same 5 companies so everything stays the same, I'm just going to add the figures for this Monday (i.e the debt in pounds).
The 3rd Monday (16/01) however, for one of those 5 companies (see Company C) the debt drops from around £91k to £23k and that company is not within the top 5. I will need that company to still remain in my table but I also need to add an extra company that's now on my top 5 list (Company F in this example)
- you can see from example I've attached that UK has 6 companies, while RFR (France) has 5 companies


Any idea how this can be achieved with or without VBA?

Many thanks in advance


example.xlsx
ABCDEFGHIJKL
1COLLECTOR_NAMECOLLECTOR_ALIASPARTY_NAMEACCOUNT_NUMBERACCOUNT_NAMERU NumberOperating Unit NameCurrency_codeAnalystCountryRSSTotal 90+ EUR
2UKIK01ACompany A100000181Company A289936783UKGBPAgent 1United KingdomUK€ 9,220.09
3UKIK01ACompany B90021323000794Company B289936783UKGBPAgent 2United KingdomUK-€ 343.77
4IECC60ACompany C10000523033Company C289936783IEEURAgent 3IrelandUK
5BE300.MABCompany D250021417174Company D001307081RBEEURAgent 4BelgiumUK
6MARINA.JORDAN RGSECCompany E1004537456Company E315034629RDEEURAgent 5GermanyUK€ 255,450.15
Source Data



example.xlsx
ABCDEFGHI
1Sum of Total 90+ EUR
2UKBATL02/01/202309/01/202316/01/202323/01/202330/01/2023 Weekly Comments
3Company AAgent 1TL 1£ 122,478.38£ 121,519.89£ 110,815.29
4Company BAgent 2TL 2£ 98,514.95£ 98,420.18£ 98,139.99
5Company CTBCTL 3£ 91,733.20£ 91,678.77£ 23,915.53
6Company DAgent 3TL 4£ 89,167.26£ 69,687.55£ 69,489.15
7Company ETBCTL 3£ 62,137.17£ 62,237.31£ 62,060.13
8Company FAgent 4TL 6£ -£ -£ 60,946.74
9Sum of Total 90+ EUR
10RFR
11Company GTBCTL 3£ 151,135.50£ 151,135.50£ 151,135.50
12Company HTBCTL 3£ 108,173.03£ 108,173.03£ 107,900.40
13Company ITBCTL 3£ 91,324.75£ 91,324.75£ 91,324.75
14Company JTBCTL 3£ 97,407.19£ 95,339.20£ 89,224.69
15Company KTBCTL 3£ 98,660.48£ 98,660.48£ 85,786.87
16Total£ 1,010,731.91£ 988,176.66£ 950,739.04
Table
Cell Formulas
RangeFormula
A2A2=INDEX('[Debt Dashboard v0.2.xlsb]REFERENCE'!$I$15:$I$34,1)
D2D2=DATE(YEAR(TODAY()),MONTH(TODAY()),8)-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),6))
E2E2=DATE(YEAR(TODAY()),MONTH(TODAY()),15)-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),6))
F2F2=DATE(YEAR(TODAY()),MONTH(TODAY()),22)-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),6))
G2G2=DATE(YEAR(TODAY()),MONTH(TODAY()),29)-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),6))
H2H2=DATE(YEAR(TODAY()),MONTH(TODAY()),36)-WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),6))
A10A10=INDEX('[Debt Dashboard v0.2.xlsb]REFERENCE'!$I$15:$I$34,2)
D16:F16D16=SUM(D3:D15)
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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