![]() We would love to hear from you, do let us know how we can improve our work and make it better for you. Also, you can follow us on Twitter and Facebook. If you liked this blog, share it with your friends on Facebook. 'Checking that year should not have negative value 1 is added as we want to find the first day of the week.įunction WeekStartDate(intWeek As Integer, intYear As Integer, Optional intMonth As Integer = 1, Optional intDay As Integer = 1) If week day value is less than 4, then current week is considered as first week. ![]() Weekday function is used to get the week day for the date, considering Monday as the first day of the week.Ībove code is used to find the number of days to be included to find the first date of the week. Type: (serialnumber,returntype) We can use the WEEKNUM function as follows: Range ('B2') Application.WeekNum (Range ('A2')) Range ('B3') Application.WeekNum (Range ('A3')) Range ('B4') Application. Otherwise, if week day of the given date is greater than 4 then next week will be considered as first week.ĭateSerial function is used to get date from the day, month and year value. WEEKNUM Examples in VBA You can also use the WEEKNUM function in VBA. Logic used for this function is that if week day of the given date is less than 4, then current week will be considered as the first week. We have created “WeekStartDate” custom function to find the first day of the week. If both Month and Day parameter are not specified then it will return the first day of specified week of the year. If Day parameter is not specified then it will return the first day of the week after specified number of week in the month specified by the Month parameter of the specified year. WeekStartDate function returns the first day of the week after specified number of weeks from the date specified by the Day, Month and Year parameter. This function assumes Monday as first day of the week. WeekStartDate(WeekNumber, Year, Month, Day) ![]() Syntax for custom function “WeekStartDate” is Based on these input values, function will return the first day for the week. Custom function will have day, month, year and week number as input parameters. In this article, raw data consists of week number, day, month and year. We will create a custom function which will return the first date of the week after specified number of week from the given year, month or date. In this article, we will create a user defined function (UDF) or custom function to find the first date for any given week, considering Monday as the first day of the week.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |