Msgbox when value for this year to date greater than this time last year

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. 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.

Fri, 26 Nov 2021REST
Sat, 27 Nov 2021OTHER (IB)
Sun, 28 Nov 2021Hallas 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 home12.2
Mon, 29 Nov 2021OTHER (IB)
Tue, 30 Nov 2021Cull. Rd/Viaduct/Stn Rd Haworth Rd/Shay Lane/ Crack Lane/Main Street/ Bents Lane/Hallas Bridge (18/12/2018)5.0
Wed, 1 Dec 2021REST
Thu, 2 Dec 2021Cullingworth 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:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I have re-thought the above and have identified what might be a more straightforward method of constructing a solution, using sheet 'Daily Tracking' instead of 'Training Log'.

The first range (Column A) shows headings for the second range.

MrExcel (no codes).xlsx
A
369TRUE YR
370AGE/YR#
371DAY YTD
372MLG YTD
373RANK/40
374PROJ. Y/E
375ACTL. Y/E
376RANK/40
377AVE RUN
378RANK/40
379DAYS
Daily Tracking
Cell Formulas
RangeFormula
A373,A378,A376A373="RANK/"&YearEndRank


The second range relevant rows are
- AN369:CC369 which are years from 2020 to 2061 (extract just goes up to 2030)
- AN372:CC372 which are year to date mileages totals as above
- AN379:CC379 which are year to date run totals as above

MrExcel (no codes).xlsx
ANAOAPAQARASATAUAVAWAX
36920202021202220232024202520262027202820292030
37058/3959/4060/4161/4262/4363/4464/4565/4666/4767/4868/49
371339338
372347399
3732523
374353453
375347399
3762524
3776.49.7
378112
3795441
Daily Tracking
Cell Formulas
RangeFormula
AN371:AO371AN371= YEP_LastDate - $A$2 + 1 + (YEP_LastDate>$A60)*(2-MONTH(DATE(AN$1,2,29)))
AN372:AO372AN372= SUMPRODUCT(--($A2:$A367<=YEP_LastDate),AN2:AN367)
AN373:AO373AN373=RANK(AN372,$B$372:$CC$372)
AN374:AO374AN374=AN372 + (SUMPRODUCT(--ISNUMBER($A2:$A367),--($A2:$A367>DATE(YEAR($A$2)+1,1,AN371-90)),AM2:AM367) + SUMPRODUCT(--($A2:$A367>YEP_LastDate-90),--($A2:$A367<=YEP_LastDate),AN2:AN367))/90 * (DaysInCurYear-AN371)
AN375:AO375AN375=SUMPRODUCT(--(ISNUMBER($A$1:$A$370)),(AN$1:AN$370))
AN376:AO376AN376=RANK(AN375,$B$375:$CC$375)
AN377:AO377AN377=AN375/AN379
AN378:AO378AN378=RANK(AN377,$B$377:$CC$377)
AN379:AO379AN379=COUNTIF(AN2:AN367,">0")
Named Ranges
NameRefers ToCells
CurYTD=OFFSET('Daily Tracking'!$Y$375,0,YEAR(TODAY())-2005)AO376:AO377, AN376
DAY_YTD=INDEX('Daily Tracking'!$371:$371,1,DailyTrackingColumn)AO374
EntRng=OFFSET('Daily Tracking'!$Y$2:$Y$367,0,YEAR(TODAY())-2005)AO379, AO374:AO375, AO372
PreYTD='Daily Tracking'!$B$375:INDEX('Daily Tracking'!$375:$375,1,DailyTrackingColumn-1)AN376:AO376
'Daily Tracking'!solver_opt='Daily Tracking'!$S$375AN376:AO376
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AO379Cell Value>=330textYES
AO379Cell Valuebetween 275 and 329textYES
AO379Cell Valuebetween 243 and 274textYES
AO377:AO378Cell Valuebetween 99 and 199textYES
AO377:AO378Cell Valuebetween 200 and 365textYES
AO375Cell Valuebetween 1000 and 1249textYES
AO375Cell Valuebetween 1250 and 1499textYES
AO375Cell Value>=1500textYES
AO372Expression=AO372>=LARGE($C$375:$CC$375,1)textYES
AO372Expression=AO372>=LARGE($C$375:$CC$375,2)textYES
AO372Expression=AO372>=LARGE($C$375:$CC$375,3)textYES
AN379Cell Value>=330textYES
AN379Cell Valuebetween 275 and 329textYES
AN379Cell Valuebetween 243 and 274textYES
AN377:AN378Cell Valuebetween 99 and 199textYES
AN377:AN378Cell Valuebetween 200 and 365textYES
AN375Cell Valuebetween 1000 and 1249textYES
AN375Cell Valuebetween 1250 and 1499textYES
AN375Cell Value>=1500textYES
AN372Expression=AN372>=LARGE($C$375:$CC$375,1)textYES
AN372Expression=AN372>=LARGE($C$375:$CC$375,2)textYES
AN372Expression=AN372>=LARGE($C$375:$CC$375,3)textYES
CD381:CD383,B379:AE379,AP379:CD379Cell Value>=330textYES
CD381:CD383,B379:AE379,AP379:CD379Cell Valuebetween 275 and 329textYES
CD381:CD383,B379:AE379,AP379:CD379Cell Valuebetween 243 and 274textYES
B377:AE378,AP377:CC378Cell Valuebetween 99 and 199textYES
B377:AE378,AP377:CC378Cell Valuebetween 200 and 365textYES
B375:AE375,AP375:CC375Cell Valuebetween 1000 and 1249textYES
B375:AE375,AP375:CC375Cell Valuebetween 1250 and 1499textYES
B375:AE375,AP375:CC375Cell Value>=1500textYES
B372:AE372,AP372:CC372Expression=B372>=LARGE($C$375:$CC$375,1)textYES
B372:AE372,AP372:CC372Expression=B372>=LARGE($C$375:$CC$375,2)textYES
B372:AE372,AP372:CC372Expression=B372>=LARGE($C$375:$CC$375,3)textYES


As per my original post, I'm looking for a message box in 2 situations

1 - when the result of the formula in the cell for the current year (currently Col AO372, next year will be AP372) exceeds the previous year (currently Col AN372, next year will be AO372) 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 5 2020]".

2 - when the result of the formula in the cell for the current year (currently Col AO379, next year will be AP379) exceeds the previous year (currently Col AN379, next year will be AO379) 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 5 2020]".

I hope you can help? I'm more than happy to upload the workbook if this helps. Please just ask, thank you.

Many thanks!
 
Last edited:
Upvote 0
Good evening Paul,
Here's a couple of macros you can try.
Added an extra message box to know what the calculated values are as the existing data I have of yours doesn't satisfy the requirements for the requested message boxes.
Don't know if that's because of the data or my macros. Anyway, give this a shot and let me know, good luck.
VBA Code:
Sub For_Macro1()
    Dim ws As Worksheet
    Dim lr As Long, Rng As Range
    Dim ThisYrStartdate As Date, ThisYrEnddate As Date
    Dim LastYrStartdate As Date, LastYrEnddate As Date
    Dim ThisYrCount As Long
    Dim LastYrCount As Long
    
' sheet to work on
Set ws = Sheets("Training Log")
' range to work with
With ws
    lr = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng = .Range("A12:C" & lr)
End With
' dates to work with
ThisYrStartdate = DateSerial(Year(Date), 1, 1)
ThisYrEnddate = Date
LastYrStartdate = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate = DateAdd("yyyy", -1, Date)
' calculation of thisyrcount
ThisYrCount = Application.WorksheetFunction.CountIfs(Rng.Columns(3), ">0", Rng.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrCount = Application.WorksheetFunction.CountIfs(Rng.Columns(3), ">0", Rng.Columns(1), ">=" & LastYrStartdate, Rng.Columns(1), "<=" & LastYrEnddate)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
MsgBox "Last years count as at " & LastYrEnddate & " was " & LastYrCount & vbLf & _
       "This years count is " & ThisYrCount, , "For Info Only"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' the message box
With ws.Cells(lr, 2)
    If Left(.Value, 4) <> "REST" And Left(.Value, 5) <> "OTHER" Then
        If ThisYrCount > LastYrCount And ThisYrCount <= LastYrCount + 2 Then
            MsgBox "You have been running more times this year than last, as at " & LastYrEnddate
        End If
    End If
End With

End Sub

VBA Code:
Sub For_Macro2()
    Dim ws As Worksheet
    Dim lr As Long, Rng As Range
    Dim ThisYrStartdate As Date, ThisYrEnddate As Date
    Dim LastYrStartdate As Date, LastYrEnddate As Date
    Dim ThisYrDist As Single
    Dim LastYrDist As Single

Application.ScreenUpdating = False
' sheet to work on
Set ws = Sheets("Training Log")
' range to work with
With ws
    lr = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng = .Range("A12:C" & lr)
End With
' dates to work with
ThisYrStartdate = DateSerial(Year(Date), 1, 1)
ThisYrEnddate = Date
LastYrStartdate = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate = DateAdd("yyyy", -1, Date)
' calculation of thisyrdist
ThisYrDist = Application.WorksheetFunction.SumIfs(Rng.Columns(3), Rng.Columns(3), ">0", Rng.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrDist = Application.WorksheetFunction.SumIfs(Rng.Columns(3), Rng.Columns(3), ">0", Rng.Columns(1), ">=" & LastYrStartdate, Rng.Columns(1), "<=" & LastYrEnddate)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
MsgBox "Last years distance as at " & LastYrEnddate & " was " & LastYrDist & vbLf & _
       "This years distance is " & ThisYrDist, , "For Info Only"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' the message box
If ws.Cells(lr, 3).Value > 0 Then
    If ThisYrDist > LastYrDist And ThisYrDist <= LastYrDist + 10 Then
        MsgBox "You have run more miles this year than last, as at " & LastYrEnddate
    End If
End If

End Sub
 
Upvote 0
Many thanks for helping me Nolan!

I inserted your 2 macros in the Worksheet_Change event.

Both test msgboxes worked fine so I commented them out and I had to rename some of the "dim"s to avoid duplicates.

Other than that, everything's as it was when I pasted it into my worksheet, as below:
VBA Code:
'Macro 1 - MsgBox "You have been running more times this year than last..."
    Dim ws As Worksheet
    Dim lr As Long, Rng1 As Range
    Dim ThisYrStartdate As Date, ThisYrEnddate As Date
    Dim LastYrStartdate As Date, LastYrEnddate As Date
    Dim ThisYrCount As Long
    Dim LastYrCount As Long
 
' sheet to work on
Set ws = Sheets("Training Log")
' range to work with
With ws
    lr = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng1 = .Range("A12:C" & lr)
End With
' dates to work with
ThisYrStartdate = DateSerial(Year(Date), 1, 1)
ThisYrEnddate = Date
LastYrStartdate = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate = DateAdd("yyyy", -1, Date)
' calculation of thisyrcount
ThisYrCount = Application.WorksheetFunction.CountIfs(Rng1.Columns(3), ">0", Rng1.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrCount = Application.WorksheetFunction.CountIfs(Rng1.Columns(3), ">0", Rng1.Columns(1), ">=" & LastYrStartdate, Rng1.Columns(1), "<=" & LastYrEnddate)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
'MsgBox "Last years count as at " & LastYrEnddate & " was " & LastYrCount & vbLf & _
'       "This years count is " & ThisYrCount, , "For Info Only"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' the message box
With ws.Cells(lr, 2)
    If Left(.Value, 4) <> "REST" And Left(.Value, 5) <> "OTHER" Then
        If ThisYrCount > LastYrCount And ThisYrCount <= LastYrCount + 2 Then
            MsgBox "You have been running more times this year than last, as at " & LastYrEnddate
        End If
    End If
End With


'Macro 2 - MsgBox "You have run more miles this year than last..."
    Dim ws1 As Worksheet
    Dim lr2 As Long, Rng2 As Range
    Dim ThisYrStartdate1 As Date, ThisYrEnddate1 As Date
    Dim LastYrStartdate1 As Date, LastYrEnddate1 As Date
    Dim ThisYrDist As Single
    Dim LastYrDist As Single

Application.ScreenUpdating = False
' sheet to work on
Set ws1 = Sheets("Training Log")
' range to work with
With ws1
    lr2 = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng2 = .Range("A12:C" & lr2)
End With
' dates to work with
ThisYrStartdate1 = DateSerial(Year(Date), 1, 1)
ThisYrEnddate1 = Date
LastYrStartdate1 = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate1 = DateAdd("yyyy", -1, Date)
' calculation of thisyrdist
ThisYrDist = Application.WorksheetFunction.SumIfs(Rng2.Columns(3), Rng2.Columns(3), ">0", Rng2.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrDist = Application.WorksheetFunction.SumIfs(Rng2.Columns(3), Rng2.Columns(3), ">0", Rng2.Columns(1), ">=" & LastYrStartdate, Rng2.Columns(1), "<=" & LastYrEnddate)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
'MsgBox "Last years distance as at " & LastYrEnddate1 & " was " & LastYrDist & vbLf & _
'       "This years distance is " & ThisYrDist, , "For Info Only"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' the message box
If ws1.Cells(lr2, 3).Value > 0 Then
    If ThisYrDist > LastYrDist And ThisYrDist <= LastYrDist + 10 Then
        MsgBox "You have run more miles this year than last, as at " & LastYrEnddate
    End If
End If
As the total miles for 2021 is already greater than 2020, I increased the value in one of the cells for 2020 so the total would be within the critical range. I then entered a value of 5 in the last row of Col C so the 2020 total would be exceeded within the range and the msgbox would then be triggered, but I'm afraid nothing happened.

I also reduced the number of non "REST" and "OTHER" entries for 2021 so it equalled 2020 and then entered a test entry to trigger the "number of runs" macro. Again, nothing I'm afraid.

I disabled other sheet_change event macros in case they were interfering and repeated the above, but still no msgboxes.

Would you like me to paste the other code in the worksheet_change event? How else can I help? I can upload the workbook with only this sheet code and in a different format if that would help?

Thanks again.
 
Last edited:
Upvote 0
Upload the workbook, with all code and data adjustments you have made so that I can just open the workbook, change the route and the mileage in the last record of the "Training Log" sheet to see what happens, thanks
 
Upvote 0
Sure - and thank you again.

The attached is the up to date workbook, without workbook_open event code, as you had trouble opening it.

I tested your code in a test workbook, so your above code isn't included, I hope that's OK.

Here
 
Upvote 0
If you uncomment the info message boxes, do the numbers they give make sense and would they satisfy the If(s) for the other message boxes to appear?

Edit: added this
running the stand alone macros on the workbook you've just posted
for macro 1
the count is ok, 54 and 56, but the message box won't display because the last record isn't a route
for macro 2
the mileage info differs by 164.4 miles which is a greater than the 10 you asked for.
 
Last edited:
Upvote 0
When I uncommented the test message boxes, the numbers were correct and made sense (I know they were only for test purposes, but just to let you know that the 2 messages appeared each time I entered a value in the next column in the row).

When your code was running, the other code in the change_event was also running and your intended message boxes ("You have run more miles/times this year" etc) didn't run. I then commented out all the other code in the change_event, assuming some of the other code was interfering, but it made no difference, as described above.

I hope that answers your question?

Edit:
Macro 1: Understood, but when I tested your code I added a new entry so the latest entry would be a route. ***BTW, 56 is 2 greater, not less than 2 i.e. 1 greater so it shouldn't trigger?***
Macro 2: Understood, 10 remains the requirement. When I tested your code I added 164 miles to 2020 and then added an entry in the last row to trigger the message box when it was greater by less than 10 miles.
 
Last edited:
Upvote 0
Try these two macros as stand alones only.
Let me know if they work or
if they don't work, tell me which IF line is not satisfied enroute to the message box.

VBA Code:
Sub For_Macro1_v2()
    Dim ws As Worksheet
    Dim lr As Long, Rng As Range
    Dim ThisYrStartdate As Date, ThisYrEnddate As Date
    Dim LastYrStartdate As Date, LastYrEnddate As Date
    Dim ThisYrCount As Long
    Dim LastYrCount As Long
    
' sheet to work on
Set ws = Sheets("Training Log")
' range to work with
With ws
    lr = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng = .Range("A12:C" & lr)
End With
' dates to work with
ThisYrStartdate = DateSerial(Year(Date), 1, 1)
ThisYrEnddate = Date
LastYrStartdate = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate = DateAdd("yyyy", -1, Date)
' calculation of thisyrcount
ThisYrCount = Application.WorksheetFunction.CountIfs(Rng.Columns(3), ">0", Rng.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrCount = Application.WorksheetFunction.CountIfs(Rng.Columns(3), ">0", Rng.Columns(1), ">=" & LastYrStartdate, Rng.Columns(1), "<=" & LastYrEnddate)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
MsgBox "Last years count as at " & LastYrEnddate & " was " & LastYrCount & vbLf & _
       "This years count is " & ThisYrCount, , "For Info Only"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Stop    'USE THE F8 KEY FROM HERE TO END SUB

' the message box
With ws.Cells(lr, 2)
    If Left(.Value, 4) <> "REST" Then
        If Left(.Value, 5) <> "OTHER" Then
            If ThisYrCount > LastYrCount Then
                If ThisYrCount <= LastYrCount + 2 Then
                    MsgBox "You have been running more times this year than last, as at " & LastYrEnddate
                End If
            End If
        End If
    End If
End With
End Sub


VBA Code:
Sub For_Macro2_v2()
    Dim ws As Worksheet
    Dim lr As Long, Rng As Range
    Dim ThisYrStartdate As Date, ThisYrEnddate As Date
    Dim LastYrStartdate As Date, LastYrEnddate As Date
    Dim ThisYrDist As Single
    Dim LastYrDist As Single

Application.ScreenUpdating = False
' sheet to work on
Set ws = Sheets("Training Log")
' range to work with
With ws
    lr = .Range("A:C").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set Rng = .Range("A12:C" & lr)
End With
' dates to work with
ThisYrStartdate = DateSerial(Year(Date), 1, 1)
ThisYrEnddate = Date
LastYrStartdate = DateAdd("yyyy", -1, ThisYrStartdate)
LastYrEnddate = DateAdd("yyyy", -1, Date)
' calculation of thisyrdist
ThisYrDist = Application.WorksheetFunction.SumIfs(Rng.Columns(3), Rng.Columns(3), ">0", Rng.Columns(1), ">=" & ThisYrStartdate)
' calculation of lastyrcount
LastYrDist = Application.WorksheetFunction.SumIfs(Rng.Columns(3), Rng.Columns(3), ">0", Rng.Columns(1), ">=" & LastYrStartdate, Rng.Columns(1), "<=" & LastYrEnddate)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'for info only during testing, delete when satisfied
MsgBox "Last years distance as at " & LastYrEnddate & " was " & LastYrDist & vbLf & _
       "This years distance is " & ThisYrDist, , "For Info Only"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Stop    'USE THE F8 KEY FROM HERE TO END SUB

' the message box
If ws.Cells(lr, 3).Value > 0 Then
    If ThisYrDist > LastYrDist Then
        If ThisYrDist <= LastYrDist + 10 Then
            MsgBox "You have run more miles this year than last, as at " & LastYrEnddate
        End If
    End If
End If
End Sub
 
Upvote 0
Hi Nolan

Macro 1 - The number count for last year in the test message is shown as 48 but it's actually 54 (the last row the code counted was 8207 for June 9 2020 - you'll see this when you check the workbook), so I deleted 7 entries from this year, to reduce the number for this year to 49 to trigger the message box. The good news is when I keyed F8 line by line I got the message box, so that one works! :)

Macro 2 - Similarly, the mileage sum for last year in the test message is also incorrect at 326.9 (the last row the code summed was also 8207 for June 9 2020) and it should be 347. I therefore increased last year's mileage to between 327 and 337 (making sure to use an entry before 9 June so it would be included) so it would trigger the message box. Unfortunately, no message box with this one though. I keyed F8 line by line and each line highlighted yellow, just like Macro 1, the only difference was no message box.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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