VBA Get Next Date using VBA Functions

VBA Get Next Date

VBA Get Next Date using Excel VBA Functions. Date plays an important major role in data analysis to summarize data, to create graphs and dashboards based on date. We also format date using format function in multiple ways.

Macro to find Next Date using VBA

Let us see the procedure how to find Next Date using VBA Date and Format functions.

'Procedure to Get Next Date
Sub VBA_Next_Date()
    
    'Variable declaration
    Dim dDate As Date
    
    'Get next date
    dDate = DateAdd("d", 1, Date)
    
    'Display next date
    MsgBox "If today's date is " & Date & vbCrLf & _
    "then the next date is :" & dDate, vbInformation, "Get Next Date"
    
End Sub

Here is the output screen shot of the above macro procedure.
VBA Get Next Date

Format Date in different ways:

We have different format methods to format Date. You can find output in an immediate window.

'Format Date
Sub VBA_Format_Date()
    
    'Variable declaration
    Dim dDate As String
    
    dDate = Format(Date, "ddmmyy")
    Debug.Print dDate
    
    dDate = Format(Date, "ddmmyyyy")
    Debug.Print dDate
    
    dDate = Format(Date, "ddmmmyyyy")
    Debug.Print dDate
    
    dDate = Format(Date, "ddmmmyy")
    Debug.Print dDate
    
    dDate = Format(Date, "dd/mmm/yy")
    Debug.Print dDate
    
    dDate = Format(Date, "dd-mmm-yy")
    Debug.Print dDate
    
    dDate = Format(Date, "dddd ddmmmyy")
    Debug.Print dDate
    
    dDate = Format(Date, "dddd dd mmm yy")
    Debug.Print dDate
        
End Sub

Output screenshot: Here is the output screenshot for your reference.
VBA Format Date

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

Leave a Comment