Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
The below sheet 'Training Log' extract contains the following info:
Column A (starting Row 12, currently Row 8748 and added to daily) contains dates for every day since Jan 1 1998.
Column B contains either text either beginning with "REST", "OTHER" or a route description.
Column C contains a number greater than zero (miles run) or is blank.
I'd be very grateful for 2 macros, which are quite similar:
Macro 1
Looks at Columns A and B from Jan 1 in the current year (whichever year that is) to today's date. It then counts the number of cells with a route description (i.e. excludes text strings beginning with "REST" and "OTHER").
It will then do the same for Columns A and B from Jan 1 in the previous year (whichever year that is) and compares the two totals.
If a route description has been entered in the last row of Column B and the total for the current year is greater than the total for the previous year by less than 2 then a msgbox appears with "You have been running more times this year than last, as at [whatever today's date last year is e.g. Dec 3 2020]".
Macro 2
Looks at Columns A and C from Jan 1 in the current year (whichever year that is) to today's date. It then sums the values of those cells and does the same for Columns A and C from Jan 1 in the previous year (whichever year that is) and compares the two.
If a value greater than zero has been entered in the last row of Column C and the value for the current year is greater than the value for the previous year by less than 10 then a msgbox appears with "You have run more miles this year than last, as at [whatever today's date last year is e.g. Dec 3 2020]".
Hope you can help?
Many thanks!
The below sheet 'Training Log' extract contains the following info:
Column A (starting Row 12, currently Row 8748 and added to daily) contains dates for every day since Jan 1 1998.
Column B contains either text either beginning with "REST", "OTHER" or a route description.
Column C contains a number greater than zero (miles run) or is blank.
Fri, 26 Nov 2021 | REST | |
Sat, 27 Nov 2021 | OTHER (IB) | |
Sun, 28 Nov 2021 | Hallas Br/Down Bents Ln Harden Lane/Smithy Ln/ Lee Farm/Blackhills/Golf Course/R down Beck Foot Lane/Wagon Lane/Down LLC to Hirst Wood Lock (to post)/Back up to 5-Rise Locks/Down to 3-Rise & over Br/Brown Cow/Main Rd all the way back home | 12.2 |
Mon, 29 Nov 2021 | OTHER (IB) | |
Tue, 30 Nov 2021 | Cull. Rd/Viaduct/Stn Rd Haworth Rd/Shay Lane/ Crack Lane/Main Street/ Bents Lane/Hallas Bridge (18/12/2018) | 5.0 |
Wed, 1 Dec 2021 | REST | |
Thu, 2 Dec 2021 | Cullingworth Rd/Viaduct/ Stn Road/Old Allen Road Back Lane/Wilsden Rd/ Cottingley Rd/Lee Lane/ Cross Lane/Coplowe Ln/ Crack Lane/Main Street/ Harden Ln/Mill Hill Top/ Wilsden Rd/Mad Mile/ Greenside Lane (21/02/2020) | 10.6 |
I'd be very grateful for 2 macros, which are quite similar:
Macro 1
Looks at Columns A and B from Jan 1 in the current year (whichever year that is) to today's date. It then counts the number of cells with a route description (i.e. excludes text strings beginning with "REST" and "OTHER").
It will then do the same for Columns A and B from Jan 1 in the previous year (whichever year that is) and compares the two totals.
If a route description has been entered in the last row of Column B and the total for the current year is greater than the total for the previous year by less than 2 then a msgbox appears with "You have been running more times this year than last, as at [whatever today's date last year is e.g. Dec 3 2020]".
Macro 2
Looks at Columns A and C from Jan 1 in the current year (whichever year that is) to today's date. It then sums the values of those cells and does the same for Columns A and C from Jan 1 in the previous year (whichever year that is) and compares the two.
If a value greater than zero has been entered in the last row of Column C and the value for the current year is greater than the value for the previous year by less than 10 then a msgbox appears with "You have run more miles this year than last, as at [whatever today's date last year is e.g. Dec 3 2020]".
Hope you can help?
Many thanks!
Last edited: