Displaying current uk tax year using vba

  • Hi,


    Part of the user form that I am using displays the current tax year automatically when tabbed into it from the following code:


    Code
    Private Sub TaxYear_enter()
    
    
    TaxYear = format (date("yy")-1 & " / " & format(date("yy")
    
    
    End Sub


    this is great if the system date is less than or equal to 05/04/yyyy, however, if the system date is greater than or equal to 06/04/yyyy then the tax year would have to be displayed as


    Code
    Private Sub TaxYear_enter()
    
    
    TaxYear = format (date("yy") & " / " & format(date("yy") +1
    
    
    End Sub


    unfortunately my vba is limited and i am looking for vba code that will be able to do this comparison with the system date and then display the correct tax year (result) in the format yy / yy (i.e 12 / 13 for current date or 13 / 14 after 6th April 2013 and be automatically adjusted for future subsequent years)


    many thanks...

  • Re: Displaying current uk tax year using vba


    I would use the initialize event of the userform & a label to display the year. A Textbox can be manually altered, a label cannot.


  • Re: Displaying current uk tax year using vba


    H Royuk


    unfortunately a textbox has to be used as it is bookmarked onto a word doc that get printed out once the userform is filled in. The textbox has now been disabled to accept user input therefore cannot be edited.


    I have however utilized your recommendation and coding to produce the following that gives me the result that I was looking for.


    Code
    Private Sub TaxYear_enter()
    Dim yr As Integer
    yr = Year(Date)
    If Date >= CDate("04/06/" & yr) Then TaxYear = Format(Date, "yy") & " / " & Format(Date, "yy") + 1
    If Date <= CDate("04/06/" & yr) Then TaxYear = Format(Date, "yy") - 1 & " / " & Format(Date, "yy")
    End Sub


    many thanks for pushing me in the right direction.


    greatly appreciated...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!