Greater than Less than troubles

heilagr

New Member
Joined
May 2, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am struggling with getting the correct month to display with my less than/greater than formula. I want it to display the previous month if the number in the cell its pulling from is less than 15 and to display the current month if the number in the cell is greater than 15.

Theoretically my formula should display "April" if the number in cell AZ20 is less than 15 and should display "May" if the number in cell AZ20 is greater than 15. Instead it is displaying "May" no matter what the number in cell AZ20 is (manually changed the date on my computer to test the formula - also tried in airplane mode to see if that made a difference). If I reverse the </> "April" will show no matter what the number is in cell AZ20.

I've included screenshots of both the correct </> and reversed with today's date and with the date bumped forward to show the change between reverse </> and no change despite the number in cell AZ20 being different. Where am I going wrong??

My formula is:

=IF(15<AZ20,(TEXT(TODAY(),"MMMM")),IF(15>AZ20,(TEXT(TODAY()-DAY(TODAY()),"MMMM"))))

Cell AZ20 is a formula that displays the current date:

=TEXT(TODAY(),"DD")
 

Attachments

  • Correct.jpg
    Correct.jpg
    120.5 KB · Views: 13
  • Correct2.jpg
    Correct2.jpg
    110.9 KB · Views: 13
  • reversed.jpg
    reversed.jpg
    113.7 KB · Views: 6
  • reversed2.jpg
    reversed2.jpg
    111.5 KB · Views: 13

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
When I test the formula it works fine for me. Perhaps the spreadsheet's calculations have been turned to manual? Can you check this:
Ribbon -> Formulas -> Calculation Options -> Should be automatic:
1651530243156.png


If it's on manual, it will not recalulcate the output of the formula when you change cells.
 
Upvote 0
Hi & welcome to Mr Excel.
If this is the formula in AZ20 =TEXT(TODAY(),"DD") then it will always be greater than 15 as it returns text & not a number.
Try using
Excel Formula:
=TEXT(TODAY(),"DD")+0
 
Upvote 0
Following on from @Fluff's insight.
If you don't want to change AZ20 then change your formula to something like this:-
Excel Formula:
=IF(VALUE(AZ20)>15,TEXT(TODAY(),"MMMM"),TEXT(TODAY()-DAY(TODAY()),"MMMM"))

You could change AZ20 to something like this which returns a number:-
Excel Formula:
=DAY(TODAY())
In which case you can drop the VALUE from the above formula and use:-
Excel Formula:
=IF(AZ20>15,TEXT(TODAY(),"MMMM"),TEXT(TODAY()-DAY(TODAY()),"MMMM"))
 
Upvote 0
Solution
Following on from @Fluff's insight.
If you don't want to change AZ20 then change your formula to something like this:-
Excel Formula:
=IF(VALUE(AZ20)>15,TEXT(TODAY(),"MMMM"),TEXT(TODAY()-DAY(TODAY()),"MMMM"))

You could change AZ20 to something like this which returns a number:-
Excel Formula:
=DAY(TODAY())
In which case you can drop the VALUE from the above formula and use:-
Excel Formula:
=IF(AZ20>15,TEXT(TODAY(),"MMMM"),TEXT(TODAY()-DAY(TODAY()),"MMMM"))
This worked! Thank you so much! This was driving me crazy
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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