Click here to Skip to main content
15,906,301 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends

I have a excel sheet there are two column 1 contain month and second contain Year.
now in third column I want financial year column like January 2013 is the financial Year 2012-2013, same as June 2013 is financial year 2013-1014

please help me to create micro or any formula in excel .
Posted
Comments
ZurdoDev 27-Sep-13 7:49am    
It's a macro, not micro. And what's your question? You can record macros so that is where you should start.

Steps to do:
1) add new module
2) copy and paste below code
VB
Function FinancialYear(m As Integer, y As Integer) As String
Dim sRetVal As String

    If m >= 6 And m <= 12 Then
        sRetVal = y & "-" & y + 1
    ElseIf m >= 1 And m <= 5 Then
        sRetVal = y - 1 & "-" & y
    Else
        sRetVal = "Over the range!"
    End If
    
FinancialYear = sRetVal

End Function

3) Insert formula in C column:
VB
=FinancialYear(A1;B1)

4) Do the 3. step for each cell
5) Done!

Example result:
A       B       C
1	2013	2012-2013
2	2013	2012-2013
3	2013	2012-2013
4	2013	2012-2013
5	2013	2012-2013
6	2013	2013-2014
7	2013	2013-2014
8	2013	2013-2014
9	2013	2013-2014
10	2013	2013-2014
11	2013	2013-2014
12	2013	2013-2014
13	2013	Over the range!
 
Share this answer
 
Comments
Richard MacCutchan 27-Sep-13 9:22am    
You obviously worked harder than me, and actually tested your code. +5
Maciej Los 27-Sep-13 9:25am    
Thank you very much, Richard!
It's just a formula, something like:
JavaScript
IF MONTH(B1) < 6 THEN C1 = TEXT(YEAR(B1) - 1) + "-" + TEXT(YEAR(B1))
      ELSE C1 = TEXT(YEAR(B1)) + "-" + TEXT(YEAR(B1) + 1)

Note: this is not an exact formula but you should get the idea.
 
Share this answer
 
Comments
Maciej Los 27-Sep-13 8:49am    
Excellent pseudo-code!
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900