

There is another way to convert a date’s format into another format as needed. Step 6: We will see in the message box, the Format function has converted it into 01-05-2019 as shown below. Step 5: As per the syntax of the Format function, we will now use the DD variable and the format in which we want to convert the mentioned number into a date as shown below. Step 4: To see the output, here we will use the message box as shown below with the FORMAT function. Here we have chosen 43586 as shown below. Step 3: Put any number which we would like to see that converting into a date. We have chosen Variant as it would allow most of the characters in it. Step 2: Now using DIM declare a variable choosing the data type as a Variant. Step 1: For this again we would need a module and in that write the subprocedure for VBA Format Date. There is another way to change the Format of Date in VBA. We will see the Date at cell A1 is now changed to DD.MM.YY and visible as 25.06.20. Step 6: Run the code by pressing F5 or Play Button is mentioned below the menu bar. Step 5: As per the syntax of the Format function, choose the format by which we want to change the Date of the selected cell. Step 4: Then use the Number Format function as shown below. Step 3: Choose the range cell first as A1. Step 2: Write the subprocedure for VBA Format Date or choose anything to define the module.

Step 1: Insert a new module inside Visual Basic Editor (VBE).
