15,920,704 members
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

Posted
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.

## Solution 1

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.

Maciej Los 27-Sep-13 8:49am
Excellent pseudo-code!
+5!

## Solution 2

Steps to do:
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!```

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!