VBA DAY Function

HomeVBA Functions LIST (Category Wise)How to use the VBA DAY Function (Syntax + Example)

What is VBA DAY Function

how to use it

To use VBA's DAY function you need to understand its syntax and arguments:




  • Date: A valid date as per VBA from which you want to get the day.

Example to use DAY Function in VBA

To practically understand how to use VBA DAY function, you need to go through the below example where we have written a vba code by using it:

Sub example_DAY()
Range("B1").Value = Day(Range("A1"))
End Sub

In the above example, we have used DAY to get the day number from the date which we have in the cell A1 and it has returned the 15 in the result as the date is the 15-May-19.


Below are some important points which you need to take care while using DAY function in VBA.

  • If the value specified is a value other than a date or a date that can't be recognized as a date, VBA will return the run-time 13 error.
  • And if the date is NULL, it will return NULL.

Related Functions

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.