IF function - formula help

seanxx

New Member
Joined
Apr 11, 2018
Messages
17
Office Version
  1. 2019
Platform
  1. Windows
Please help me, what formula should I use?

when in cell G4=28.2.2024, then
G6=06

G4=28.2.2025, then
G6=P6

G4=28.2.2026, then
G6=Q6

thank you

EN vlastne.xlsx
DEFGHIJKLMNOPQRS
1
2
3TODAY
419.3.202428.2.20242024202520262027
52 0242 0252 026170
6FALSE200120150180
7300130160190
8
9
Hárok1
Cell Formulas
RangeFormula
F4F4=TODAY()
G4G4=DATE(YEAR(F4)-IF(F4<=DATE(YEAR(F4),2,28),1,0),2,28)
G6G6=IF(G4="28.2.2024",$O$5,IF(G4="28.2.2025",$P$5,IF(G4="28.2.2026",Q5)))
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this:
Excel Formula:
=IF(YEAR(G4)=2024,O6,IF(YEAR(G4)=2025,P6,IF(YEAR(G4)=2026,Q6,"")))
 
Upvote 1
Solution
deleted. Was thinking incorrectly.
Joe has a solution for you.

But what exactly are you trying to do? Are you trying to return the values in Rows 7 or 8 as well?

Best Wishes.
 
Upvote 0
Try this:
Excel Formula:
=IF(YEAR(G4)=2024,O6,IF(YEAR(G4)=2025,P6,IF(YEAR(G4)=2026,Q6,"")))
yes perfect

this is how it works.
thank you.

May I ask where did I go wrong, why didn't it work for the date?
How to write a formula when I need an exact date (dd.mm.yyyy)
 
Upvote 0
I think the issue is that this format:
Excel Formula:
=IF(G4="28.2.2024"...
is checking for a text value of "28.2.2024" (double-quotes usually indicate literal text and not dates).

You could use this:
Excel Formula:
=IF(G4=DATE(2024,2,28)...
or perhaps something like the below, depending on your regional date settings (may be different for different people):
Excel Formula:
=IF(G4=DATEVALUE("28.2.2024")...
I am not sure what your regional date settings are, so I cannot say if that will work for you.
Just change the format of the date between the double-quotes to match your regional date settings.
 
Upvote 1
I would also add, that using text to record dates, in the long run causes more headaches than you think. Just format the cells to a date format (any one you like) and excel will work fine.
To get components out of those values you use the Year(), Month(), Day(), Hour(), Minute(), Second() functions. And plenty of other date related functions. When you must compare something to a text like "Sat" just use the Text(value, format) function to convert the date to the text string you need, in the case I just mentioned" Text(date,"ddd") would give you a 3 digit string for the day of ht week name.
 
Upvote 1
I think the issue is that this format:
Excel Formula:
=IF(G4="28.2.2024"...
is checking for a text value of "28.2.2024" (double-quotes usually indicate literal text and not dates).

You could use this:
Excel Formula:
=IF(G4=DATE(2024,2,28)...
or perhaps something like the below, depending on your regional date settings (may be different for different people):
Excel Formula:
=IF(G4=DATEVALUE("28.2.2024")...
I am not sure what your regional date settings are, so I cannot say if that will work for you.
Just change the format of the date between the double-quotes to match your regional date settings.
yes perfect

The other two formulas also work,
I just changed mine "," → ";"

thank you very much for the explanation.
 
Upvote 0
I would also add, that using text to record dates, in the long run causes more headaches than you think. Just format the cells to a date format (any one you like) and excel will work fine.
To get components out of those values you use the Year(), Month(), Day(), Hour(), Minute(), Second() functions. And plenty of other date related functions. When you must compare something to a text like "Sat" just use the Text(value, format) function to convert the date to the text string you need, in the case I just mentioned" Text(date,"ddd") would give you a 3 digit string for the day of ht week name.
I'm going to try and learn

thank you very much for the explanation.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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