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 (weekday) name by using the integer supplied as the day number. In simple words, it returns the day name using the day’s number of the week (ranging from 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 an abbreviated name [This is an optional argument and if omitted VBA takes FALSE by default].
- Use TRUE for the abbreviated name (i.e. “Jan”, “Feb”, “Mar”, etc.) or FALSE for the 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 the 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.
More Tutorials
⇠ Back to VBA Function List | What is VBA in Excel
Helpful Links – Developer Tab – Visual Basic Editor – Run a Macro – Personal Macro Workbook – Excel Macro Recorder – VBA Interview Questions – VBA Codes