Multiple If statement, else statement

iluvsafc

New Member
Hi Guys,

I'm usually OK with if statements but when it comes to multiple criteria i tend to get a bit confused.

Basically when a date is inputted that falls between the below date range i want the output in the next column to be the academic year.

Hope that makes sense guys!

Cheers,
Lee
Date range

<tbody>
</tbody>
01/08/2012
 31/07/2013

<tbody>
</tbody>
 2012/13

<tbody>
</tbody>
 01/08/2013

<tbody>
</tbody>
 31/07/2014

<tbody>
</tbody>
 2013/14

<tbody>
</tbody>
 01/08/2014

<tbody>
</tbody>
 31/07/2015

<tbody>
</tbody>
 2014/15

<tbody>
</tbody>
 01/08/2015

<tbody>
</tbody>
 31/07/2016

<tbody>
</tbody>
 2015/16

<tbody>
</tbody>
 01/08/2016

<tbody>
</tbody>
 31/07/2017

<tbody>
</tbody>
 2016/17

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>

gallen

Well-known Member
Assuming your inputted date is in Cell A1. In Cell B1 put:

=IF(MONTH(A1)>7,YEAR(A1) & "/" & YEAR(A1)+1,YEAR(A1)-1 & "/" & YEAR(A1))

iluvsafc

New Member
Assuming your inputted date is in Cell A1. In Cell B1 put:

=IF(MONTH(A1)>7,YEAR(A1) & "/" & YEAR(A1)+1,YEAR(A1)-1 & "/" & YEAR(A1))
You're a star!! Thanks very much

Active Member
Assum your date is in Cell C3

=RIGHT(YEAR(C3),4)&"/"&RIGHT(YEAR(C3),2)+1

gallen

Well-known Member
You're a star!! Thanks very much
No problem, I'm good with the straight forward ones

gallen

Well-known Member
Assum your date is in Cell C3

=RIGHT(YEAR(C3),4)&"/"&RIGHT(YEAR(C3),2)+1
That won't work for dates before 1/8. You need the if statement

iluvsafc

New Member
Sorry one more thing, can you stick an 'if blank' in there for me please with an output of "Provide start date"

Cheers!

Active Member
=IF(A1="","Provide start date",IF(MONTH(A1)>7,YEAR(A1)&"/"&YEAR(A1)+1,YEAR(A1)-1&"/"&YEAR(A1)))

gallen

Well-known Member
Sorry one more thing, can you stick an 'if blank' in there for me please with an output of "Provide start date"

Cheers!
This checks if the value is at least numeric. There is no built in function to check if the user has put a valid date but at least this is a little more than just checking for a blank cell

=IF(ISNUMBER(A1), IF(MONTH(A1)>7,YEAR(A1) & "/" & YEAR(A1)+1,YEAR(A1)-1 & "/" & YEAR(A1)),"Please Enter a Valid Date")

gallen

Well-known Member
If you are familiar with the code window you could insert your own function. If you go to the code window (Alt + [F11]) then go to the Project explorer (Ctrl + R) > Right Click the 'Microsoft Excel Objects' folder and choose Insert>Module.

In the module window paste:

Code:
``````Public Function IsDateValue(r As Range) As Boolean
IsDateValue = IsDate(r)
End Function``````
Then you can use

=IF(IsDateValue(A1), IF(MONTH(A1)>7,YEAR(A1) & "/" & YEAR(A1)+1,YEAR(A1)-1 & "/" & YEAR(A1)),"Please Enter a Valid Date")

This will only accept a valid date

1,082,334
Messages
5,364,677
Members
400,810
Latest member
elbashka

This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...