Msgbox when any one of a number of subtotals has been exceeded

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

A2:A243 (which is added to regularly) contains values and subtotals for each year.

The subtotals for each year are identified in blue and by a formula in Column B.

I need a message box to appear when the value in cell A245 exceeds a subtotal.

If a trigger cell is needed, then C245 can be used (so I can easily see it), although this will need to change when a new entry is added.

Many thanks!

Book1
AB
210
211136Tue 28/01/2020
212152Wed 05/02/2020
213144Sun 09/02/2020
214166Thu 13/02/2020
215156Mon 17/02/2020
216100Fri 21/02/2020
21798Tue 25/02/2020
21897Sat 29/02/2020
219126Wed 04/03/2020
220142Sun 08/03/2020
221103Thu 12/03/2020
22211TOTAL FOR 2020
223
224135Tue 22/06/2021
22557Sat 26/06/2021
226154Wed 30/06/2021
2277Sun 04/07/2021
228120Mon 12/07/2021
229124Fri 16/07/2021
23051Tue 20/07/2021
231162Sat 24/07/2021
23272Wed 28/07/2021
233101Sun 01/08/2021
2343Thu 05/08/2021
235110Mon 09/08/2021
23640Fri 13/08/2021
23777Tue 17/08/2021
23844Sat 21/08/2021
23968Wed 25/08/2021
2402Sun 29/08/2021
24189Thu 02/09/2021
2424Mon 06/09/2021
24376Fri 10/09/2021
244
24520TOTAL FOR 2021
Iron Man Log
Cell Formulas
RangeFormula
A224:A243,A211:A221A211=RANK(D211,$D$2:$D$245)
A222A222=COUNT(A211:A221)
B222B222="TOTAL FOR " & YEAR(B221)
A245A245=COUNT(A224:A244)
B245B245="TOTAL FOR " & YEAR(B243)
Named Ranges
NameRefers ToCells
Iron_Mans_2020='Iron Man Log'!$A$211:$A$221A222
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A210Cell Value=""textNO
A245Cell Value=""textNO
A244Cell Value=""textNO
A222Cell Value=""textNO
A223Cell Value=""textNO
A2:A6,A211:A221,A182:A208,A177:A179,A153:A174,A149:A150,A138:A146,A112:A135,A98:A109,A90:A95,A87,A78:A84,A75,A68:A72,A58:A65,A55,A50:A52,A38:A43,A35,A23:A32,A9:A20,A224:A243,A46:A47Cell Value=1textYES
A2:A6,A211:A221,A182:A208,A177:A179,A153:A174,A149:A150,A138:A146,A112:A135,A98:A109,A90:A95,A87,A78:A84,A75,A68:A72,A58:A65,A55,A50:A52,A38:A43,A35,A23:A32,A9:A20,A224:A243,A46:A47Cell Value=2textYES
A2:A6,A211:A221,A182:A208,A177:A179,A153:A174,A149:A150,A138:A146,A112:A135,A98:A109,A90:A95,A87,A78:A84,A75,A68:A72,A58:A65,A55,A50:A52,A38:A43,A35,A23:A32,A9:A20,A224:A243,A46:A47Cell Valuebetween 3 and 10textYES
A2:A6,A211:A221,A182:A208,A177:A179,A153:A174,A149:A150,A138:A146,A112:A135,A98:A109,A90:A95,A87,A78:A84,A75,A68:A72,A58:A65,A55,A50:A52,A38:A43,A35,A23:A32,A9:A20,A224:A243,A46:A47,A246:A531Cell Value=""textNO
Cells with Data Validation
CellAllowCriteria
A245Whole number=12345
A222Whole number=12345
 
That's because loks for the above 3hr runs and the below 3hr run.....if one column doesn't change it will still return the previous result of that column....that way you only need 1 lot of code !
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Understood, but the other message box isn't correct though because the Col C figure for 2021 relates to Col A value of 20, but the 2007 figure is 22, yet it says it's exceeded it, which it hasn't, plus the ranking can't have changed.

One other glitch is the boxes each appear twice, although that may be because I double clicked a protected validated cell and it gave a validation error message and then I got 2 lots of your code messages instead of 1?
 
Last edited:
Upvote 0
PS - I also got the msgbox for >3hr runs for 2021 is greater than 2004 yet 2021 = 4 and 2004 = 5?
 
Upvote 0
Why is there a formula in D247 now ??
 
Upvote 0
Er, that's the data for 2021. I think I inserted another row above the table, apologies.

Here's the up to date table:

Book1
ABCDEF
2204Mon 06/09/202115.13:46:2415:001:30pm, 20-21ºC, cloudy, warm and sunny, light breeze. 11 hours of blissful sleep without being woken by that ****ing dog, then ate banana and 3 pts of squash (knew it would be warm out). Perforated t-shirt, racing shorts - perfect. Vaselined fingers, no nail-biting. Wanted to do this route but when I got out into the warm sunshine I thought I'd better play safe and go up the canal so I know how far I'll be going, but as I was approaching The Fisherman's I thought "sod it, I'm going right". And no regrets, it was pure, fresh eye candy, SO much more interesting, "this is the future of the canal runs" I thought. Much nicer setting, no monotony, so many landmarks. Complimented a beautiful woman on her nice fragrance wafting way behind her as I passed her! Echoes playing on Walkman as I approached the 2 imposing halves of Salts Mill either side of the canal - very atmospheric! Despite the views, lower back ached for the full length of the canal section. R nipple chafed from the sweat. Had planned to go back over the 3-Rise but when I saw the potential mileage I decided to go up to the top of the 5-Rise and back down (measured 0.34M from 3-Rise to top of 5-Rise - exactly the same as from home up to the junction of Bents Ln!). Wasn't as hard as I'd imagine it'd be while I was running towards Saltaire. Left hamstring got really tight from about 10M but just about held my normal stride. Got increasingly tired over last 5M but as ever - my eyes were pleading for encouragement from oncoming walkers (one or two women did!), but my head and my quads strength saw me through. My first words when I got back? "Jesus". "Jesus". I don't know how I did it. Well I do know - with a super powerful mind and strong quads from all the biking! Very satisfying run.
22176Fri 10/09/202110.62:32:4214:243:00pm, 20-18ºC, bit humid, one or two light but welcome showers. Heart bit tired B4 setting out. Vaselined fingers, no nail-biting again! Forgot to wear bandana (they were both on clothes horse upstairs) and regretted it, heavy sweating and rain were a PITA. Wore tracksters and perforated t-shirt. Pee stop junction of Old Allen Rd/Back Ln. R nipple really chafed despite vaselining it B4 setting out (bloke in car with little girl in front passenger seat going my way stopped car alongside me near bottom of Greenside Ln and asked on behalf of the little girl (!) if I was OK - assumed it was cos of me crawling up the road until I got in and saw all the blood/sweat staining down my t-shirt). I'm renaming Lee Ln/Cross Ln junction "Hungry Corner" cos more than once now I've felt hungry as I approach it! L hamstring became tight, almost normal now. Overall, run felt like a bit of a slog, probably combination of hard bike session yesterday (increased to Level 8, a lot harder) and in bed at 4am then woken 50 mins later by that ****ing dog and again at 11am.
222
223198<<< TOTAL No. IRON MAN RUNS 1984-2021
224TOTYEARRK/23No. >3HRSYEARRANK/23
22551984140198412
2261219865219867
2271019878119879
22811988200198812
22961989120198912
23021990180199012
23131991160199112
23211993200199312
2338199410519941
23451996140199612
23511998200199812
2367200011120009
23712001200200112
23862002120200212
2391220035520031
2402420042520041
241920059220057
24222006180200612
2432220073420074
2443200816120089
2452720191420194
24611202070202012
2472020214420214
Iron Man Log
Cell Formulas
RangeFormula
A220:A221A220=RANK(D220,$D$2:$D$223)
E220:E221E220=D220/C220
A223A223=COUNT(A2:A222)
B223B223="<<< TOTAL No. IRON MAN RUNS 1984-" & YEAR(B221)
C224C224="RK/"& COUNT(A225:A248)
C225:C247C225=RANK(A225,$A$225:$A$247)
D247D247=RANK(A247,$A$225:$A$247)
F224F224="RANK/"& COUNT(A225:A248)
F225:F247F225=RANK(D225,$D$225:$D$247)
Named Ranges
NameRefers ToCells
Iron_Mans_2020='Iron Man Log'!$A$190:$A$200A223
IronManLogLastYrTot='Iron Man Log'!$A$246F224, C247:D247, C224:C246
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D222Cell Value>=0.1459textNO
D222Cell Valuebetween 0.125 and 0.1458textNO
D222Cell Valuebetween 0.08333333333 and 0.12495textNO
D225:D247Cell Valuetop 1 valuestextNO
D225:D247Cell Valuetop 2 valuestextNO
D225:D247Cell Valuetop 3 valuestextNO
A225:A247Cell Valuetop 1 valuestextNO
A225:A247Cell Valuetop 2 valuestextNO
A225:A247Cell Valuetop 3 valuestextNO
D35,D27,D29,D37,D117,D223,D7,D20,D31,D33,D40:D41,D43,D47,D49,D58,D64,D66,D74,D76,D83,D96,D121,D131,D134,D157,D161,D189,D201Cell Value>=0.1459textNO
D35,D27,D29,D37,D117,D223,D7,D20,D31,D33,D40:D41,D43,D47,D49,D58,D64,D66,D74,D76,D83,D96,D121,D131,D134,D157,D161,D189,D201Cell Valuebetween 0.125 and 0.1458textNO
D35,D27,D29,D37,D117,D223,D7,D20,D31,D33,D40:D41,D43,D47,D49,D58,D64,D66,D74,D76,D83,D96,D121,D131,D134,D157,D161,D189,D201Cell Valuebetween 0.08333333333 and 0.12495textNO
A132:A133,A75,A65,A48,A32,A190:A200,A202:A221,A162:A188,A158:A160,A135:A156,A122:A130,A97:A120,A84:A95,A77:A82,A67:A73,A59:A63,A50:A57,A44:A46,A41:A42,A34:A39,A21:A30,A8:A19,A2:A6Cell Value=1textYES
A132:A133,A75,A65,A48,A32,A190:A200,A202:A221,A162:A188,A158:A160,A135:A156,A122:A130,A97:A120,A84:A95,A77:A82,A67:A73,A59:A63,A50:A57,A44:A46,A41:A42,A34:A39,A21:A30,A8:A19,A2:A6Cell Value=2textYES
A132:A133,A75,A65,A48,A32,A190:A200,A202:A221,A162:A188,A158:A160,A135:A156,A122:A130,A97:A120,A84:A95,A77:A82,A67:A73,A59:A63,A50:A57,A44:A46,A41:A42,A34:A39,A21:A30,A8:A19,A2:A6Cell Valuebetween 3 and 10textYES
Cells with Data Validation
CellAllowCriteria
C224Any value
F224Any value
F225:F247Whole number=454
C225:C246Whole number=454
D225:D247Whole number=123
C247Whole number=454
A225:A239Whole number=3364
A240Whole number=3364
A241:A245Whole number=3364
A246Whole number=12345
A247Whole number=12345
A223Whole number=12345
B223Whole number=546
 
Upvote 0
AND
why are you not using the most recent code....???
VBA Code:
Sub MM41()
Dim r As Long, lr As Long, n As Integer, fr As Long, X As Integer
lr = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A" & lr).CurrentRegion
fr = rng.Row + 1
n = Evaluate("=MAX(IF(C" & fr & ":C" & lr - 1 & "<C" & lr & ",C" & fr & ":C" & lr - 1 & ",""""))")
X = Evaluate("=MAX(IF(F" & fr & ":F" & lr - 1 & "<F" & lr & ",F" & fr & ":F" & lr - 1 & ",""""))")
For r = lr - 1 To fr Step -1
If n = Cells(r, 3) Then
    MsgBox "You've just surpassed the number of runs <= 3 hrs for " & Cells(r, 3).Offset(0, -1).Value
    n = 100
    End If
If X = Cells(r, 6) Then
    MsgBox "You've just surpassed the number of runs > 3hrs for " & Cells(r, 6).Offset(0, -1).Value
    X = 100
End If
Next r
End Sub
 
Upvote 0
Oh heavens, I don't know how that happened - I'm changing it immediately, sorry once again.
 
Upvote 0
LOL it's 3:15am, I have to keep up with you Aussies somehow :biggrin:

I promise I won't change anything else :biggrin: but I will need to insert rows above Row 223 for new runs and below Row 247 next year onwards - I hope that's OK?
 
Upvote 0
but I will need to insert rows above Row 223 for new runs and below Row 247 next year onwards - I hope that's OK?
Yep....but they need to be ABOVE row 223, not including row 223...keep 223 blank!
AND
If you are adding rows after 247 as long as they are relative to that block of data, that's fine.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,765
Members
449,049
Latest member
greyangel23

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