Show current date and time
To show the current date and time you can apply the Excel NOW Function
Example: Show current date and time
Sub Show_current_date_and_time()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply formula to calculate the current date and time
ws.Range("B5") = Now
ws.Range("B5") = Now
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analysis.
Worksheet Name: Have a worksheet named Analysis.
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("B5") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
EXPLANATION
To show the current date and time you can apply the Excel NOW Function.
To show the current date and time you can apply the Excel NOW Function.
FORMULA
=NOW()
=NOW()
ARGUMENTS
The Excel NOW Function does not accept any arguments.
The Excel NOW Function does not accept any arguments.
ADDITIONAL NOTES
Note 1: The Excel NOW Function does not accept any arguments.
Note 2: Each time the worksheet is recalculated or opened the current date and time will be updated.