Multiple If statement, else statement

iluvsafc

New Member
Joined
Jun 15, 2009
Messages
18
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
Academic Year

<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
Joined
Jun 27, 2011
Messages
1,945
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
Joined
Jun 15, 2009
Messages
18
Sorry one more thing, can you stick an 'if blank' in there for me please with an output of "Provide start date"

Cheers!
 

Muhammad_Usman

Active Member
Joined
Dec 9, 2015
Messages
324
=IF(A1="","Provide start date",IF(MONTH(A1)>7,YEAR(A1)&"/"&YEAR(A1)+1,YEAR(A1)-1&"/"&YEAR(A1)))
 

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
1,945
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
Joined
Jun 27, 2011
Messages
1,945
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
 

Forum statistics

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

Some videos you may like

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...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top