Last Updated on January 11, 2023 by token
1. WeekdayName VBA Function – Description
The WeekdayName VBA function returns the word name of the day of the week from 1 to 7. It is important that the argument for this function is a number, not a date. The function can be combined with the VBA Weekday function or with the VBA DatePart function . The function can also return the names of the days of the week in abbreviated form, eg “Mon” for Monday. To do this, we should use the second argument of the function – abbreviate.
2. VBA WeekdayName Function – Syntax
WeekdayName (Weekday As Long, [Abbreviate As Boolean = False], [FirstDayOfWeek As VbDayOfWeek = vbUseSystemDayOfWeek]) As String
Weekday : A number that represents the next day of the week from 1 to 7.
Abbreviate : Optional argument. Takes the value of True or False. It is set to False by default. If True, the day of the week name will be returned in abbreviated form, eg “Fri” for Friday.
FirstDayOfWeek : Optional argument. We can define which day is defined as the first day of the week. In Polish nomenclature it will be Monday, so vbMonday or 2.
|vbUseSystem||0||According to system / API settings|
|vbMonday||2||Monday (ISO 8601)|
Function return: String / Word name of the day of the week, eg “Thursday” or “Th”.
3. VBA WeekdayName Function – Example
How to use WeekdayName function in VBA Excel? Below is an example of using the WeekdayName function in the VisualBasic Editor.
Example 1: VBA WeekdayName Function. The result in the MsgBox window.
MsgBox WeekdayName (1) MsgBox WeekdayName (1, False, vbMonday) MsgBox WeekdayName (1, True, vbMonday) MsgBox WeekdayName (Weekday (Date), True, vbMonday)
Example 2: VBA WeekdayName VBA function. The result in the worksheet cells.
Range ("A1") = WeekdayName (3) Range ("A2") = WeekdayName (3, False, vbMonday) Range ("A3") = WeekdayName (3, True, vbMonday) Range ("A4") = WeekdayName (Weekday (Date), True, vbMonday)
4. VB WeekdayName Function – Additional information
- The function takes no dates as an argument, but numbers representing consecutive days of the week from 1 to 7. If we want to apply the function to a date, we should combine it with the WeekDay VBA or VBA DatePart function .
- The second argument to the function (abbreviate) is optional. With its help, we can return the function name in abbreviated form. Eg “Wed” for Wednesday.
- The third argument of the function is used to specify the first day of the week. For the Polish nomenclature it will be 2 or vbMonday.
5. WeekdayName VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .