If formula result = 1 then change following text from "Days" to "Day"

Ironman

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

My original post below concerned the calculation. The result precedes the words "Days Since Last Run" as in the formula below.

Original post from earlier

Excel Formula:
=TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>") &" Days Since Last Run"

I know it's pedantic but as I'm a pedant it doesn't look right grammatically when the result is 1 or if I ran today :)

Could the formula be amended or is there some code that could be used that adds either 'Day Since Last Run' in cell A9 when the result of the above formula is 1, "Days Since Last Run" when it is more than 1 or "You Ran Today" if it is 0 i.e. today?

Many thanks!
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Ugly, but should do it:

Code:
=TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>") &" Day" & IF(1=abs(TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>")),"","s")&" Since Last Run"
 
Upvote 0
Hey that works great kweaver, many thanks!

Is the '0' value condition ("You Ran Today") possible by amending the above formula or would that require code?

Thanks again!
 
Upvote 0
Code:
=IF(0=TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>"),"You Ran Today",TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>") &" Day" & IF(1=ABS(TODAY()-MAXIFS(A12:A20000,B12:B20000,"<>REST",B12:B20000,"<>OTHER",B12:B20000,"<>")),"","s")&" Since Last Run")
 
Upvote 0
Not elegant as well, but try
Excel Formula:
=SWITCH(TODAY()-MAXIFS(...),0,"You Ran Today",1,"1 Day Since Last Run",TODAY()-MAXIFS(...)&" Days Since Last Run")
 
Upvote 0
Solution
kweaver and Habtest thank you both so much, they both work equally well but I can only select 1 solution. I'm amazed at the power of formulas.
 
Upvote 0
I'm just reviewing Habtest's formula
Excel Formula:
=SWITCH(TODAY()-MAXIFS(...),0,"You Ran Today",1,"1 Day Since Last Run",TODAY()-MAXIFS(...)&" Days Since Last Run"

I need to amend this for another cell, to return the number of dates since the last REST date with "Last exercise today" if 0, "Last exercise yesterday" if 1 and "Last exercise [and actual date of exercise]" if >1. I've tried to amend it myself but have failed miserably :(

Would you be able to resolve this please?

Many thanks again!
 
Upvote 0
Something like this?
Excel Formula:
=SWITCH(TODAY()-MAXIFS(...),0,"Last exercise today",1,"Last exercise yesterday","Last exercise " &TEXT(TODAY()-MAXIFS(...),"d/mm/yyy"))
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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