In this article, we will create a custom function that returns the quarter of the year for the given date.
Raw data consists of product sales data, which consists of Sales date, Product name and Quantity.
In this article, we want to find out total quantity of products sold out on quarterly basis. So, we want to find out quarter of the year for each date.
We have used DatePart function of VBA to extract quarter of the year from the date.
Please follow below for the code
Option Explicit Function QuarterNum(Enter_Date As Date) 'Using DatePart function to extract quarter from given date QuarterNum = DatePart("q", Enter_Date) End Function
We would love to hear from you, do let us know how we can improve our work and make it better for you. Write to us at email@example.com
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.