Forum Discussion

Pradip4854's avatar
Pradip4854
Copper Contributor
Feb 05, 2023

How To change date from 2022 to 2023 in xlsx

Please help me change date from 2022 to 2023 

3 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Pradip4854 

    As far as I could understand you only want to change the year in an existing date.

    If this is so..then, I see two possibilities:

    Example in A1 = 15.5.2022 is (entered) date.

    Formula in B1

    =DATE("2023",MONTH(A1),DAY(A1))

    or alternative in B1

    =DATE(YEAR(A1)+1,MONTH(A1),DAY(A1))

     

    VBA can also be used if you convert the file to .xlsm, here is an example.

    with VBA

     

    Sub date_new()
    Dim Old, New As Date
    old="15.05.2022"
    New = DateSerial(Year(Alt) + 1, Month(Alt), Day(Alt))
    MsgBox New
    End sub

     

     

    Hope I was able to help you with this info.

     

    NikolinoDE

    I know I don't know anything (Socrates)

     

     

     

Resources