The VBA WEEKDAYNAME function is listed under the date category of VBA functions. When you use it in a VBA code, it returns the day’s (weekdays) name by using the integer supplied as the day number. In simple words, it returns the day name using the a day’s number of the week (ranging 1 to 7).
Syntax
WeekdayName(Weekday, [Abbreviate], [FirstDayOfWeek])
Arguments
- Weekday: An integer to specify the day ranging from 1 to 7.
- [Abbreviate]: A boolean value to specify if you need a full name of the month or abbreviated name [This is an optional argument and if omitted VBA takes FALSE by default].
- Use TRUE for abbreviated name (i.e. “Jan”, “Feb”, “Mar”, etc.) or FALSE for full name (i.e. “January”, “February”, “March”, etc.)
- [FirstDayOfWeek]: A string to define the first day of the week [This is an optional argument and if omitted VBA takes vbSunday by default].
- vbUseSystemDayOfWeek – As per the system settings.
- vbSunday – Sunday
- vbMonday – Monday
- vbTuesday – Tuesday
- vbWednesday – Wednesday
- vbThursday – Thursday
- vbFriday – Friday
- vbSaturday – Saturday
Example
To practically understand how to use VBA WEEKDAYNAME function, you need to go through the below example where we have written a vba code by using it:
Sub example_WEEKDAYNAME()
Range("A1").Value = WeekdayName(1, "True", vbMonday)
End Sub
In the above code, we have used WEEKDAYNAME and we have used 1 to get the first day of the week, TRUE to get the abbreviated weekday name, and vbMonday to set Monday as the first day of the week. In the result, we have Mon in cell B1.
Related Functions
DATE | DATEADD | DATEDIFF | DATEPART | DATESERIAL | DATEVALUE | DAY | MONTH | MONTHNAME | WEEKDAY | YEAR