How to Use VBA WeekdayName Function in Excel (2 Examples)

The WeekdayName function in Microsoft Excel returns a string that represents the day of the week when given a number between 1 and 7. The WeekdayName function is a Date/Time Function that is a built-in function in Excel. It can be used in Excel as a VBA function (VBA). You can use this function as a VBA function in macro code written in the Microsoft Visual Basic Editor. In this article, we’ll learn how to use the VBA WeekdayName Function with two suitable examples in Excel.


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


Introduction to the VBA WeekdayName Function

Function Objective

To get the specific day of the week, the VBA WeekdayName function is applied.

Syntax

=WeekdayName(weekday, abbreviate, firstdayofweek)

Arguments Explanation

Argument Required/Optional Explanation
weekday Required A number between 1 and 7 represents the day of the week.
abbreviate Optional If the weekday name is to be abbreviated, this is a Boolean value.

●     True – the abbreviated weekday name (i.e. “Sun”, “Mon”, “Tue”, etc.)

●     False – Return the whole weekday name (i.e. “Sunday”, “Monday”, “Tuesday”, etc.)

firstdayofweek Optional The Numeric value indicates the first day of the week. See Backgrounds section for values.

Backgrounds

The following values can be used for the firstdayofweek argument.

Constant Value Description
vbUseSystem 0 A number between 1 and 7 represents the day of the week.
vbSunday 1 Sunday
vbMonday 2 Monday
Tuesday 3
Tuesday
vbWednesday 4
Wednesday
vbThursday 5
Thursday
vbFriday 6
Friday
vbSaturday 7
Saturday

2 Suitable Examples to Use VBA WeekdayName Function in Excel

The VBA WeekdayName is not a built-in function in Excel. Only VBA code in Microsoft Excel can use the WeekdayName function. Let’s say, we have a dataset where several Employee’s Names and their Joining date are given in columns B and C respectively. We’ll use the function to convert the joining date into the name of the Day of the Week. Undoubtedly, we can do this easily by using the VBA WeekdayName function. Here’s an overview of the dataset for today’s task. We will use this dataset to explain the VBA WeekdayName function.

VBA WeekdayName


1. Find Out the Full Name Format of a Day by Using the VBA WeekdayName Function

Unquestionably, finding out the full name format of the Day of the week by using the VBA WeekdayName function is an easy task. To find out the full name format of the Day of the week, follow the instructions below.

Step 1:

Find Out the Full Name Format of a Day by Using the VBA WeekdayName Function

  • Now, from your Developer Tab, go to,

Developer → Visual Basic

  • After clicking on the Visual Basic menu, a window named Microsoft Visual Basic Applications will appear in front of you.

Find Out the Full Name Format of a Day by Using the VBA WeekdayName Function

Step 2:

  • From the Microsoft Visual Basic Applications – VBA WeekdayName Function window, go to,

Insert → Module

Find Out the Full Name Format of a Day by Using the VBA WeekdayName Function

  • A new module pops up. Now, type the below VBA Code in the module. We have provided the code here, you can just copy-paste the code and use it in your worksheet.
Sub example_weekdayName()
 Range("D5").Value = WeekdayName(1, False, vbSaturday)
End Sub

  • After inserting the code, we need to run the code to get the positive integer value. For that, go to,

Run → Run Sub/UserForm

Find Out the Full Name Format of a Day by Using the VBA WeekdayName Function

  • Finally, When running the code is completed, go back to your worksheet and you’ll be able to convert the date 01/01/22 into Day. The day is Saturday which has been given below screenshot.

Read More: VBA Format Function in Excel (8 Uses with Examples)


Similar Readings:


2. Evaluate the Short Name Format of a Day by Using the VBA WeekdayName Function

After learning the full format of the day of the Week, we will learn the short Name format of the Day of the week. Let’s try evaluating the short name Day within the same code. Please, follow the steps below to learn!

Steps:

  • Similarly, insert the below code in the VBA WeekdayName Function The code is,
Sub example_weekdayName()
 Range("D5").Value = WeekdayName(1, True, vbSaturday)
End Sub

Evaluate the Short Name Format of a Day by Using the VBA WeekdayName Function

  • From the Microsoft Visual Basic Applications window, go to,

Run → Run Sub/UserForm

  • After running the code, go back to your worksheet and you will be able to get Sat as the return of the function which has been given in the below screenshot.

Evaluate the Short Name Format of a Day by Using the VBA WeekdayName Function

Read More: How to Use the VBA Weekday Function (2 Suitable Examples)


Things to Remember

👉 If you use the VBA WeekdayName Function in a query, the firstdayofweek parameter must be a number value (from 0 to 7). In the VBA code, you can only utilize the constant equivalent (i.e. vbSunday to vbSaturday).

👉 You can perform this function in Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000 only.


Conclusion

I hope all of the suitable examples mentioned above to use the VBA WeekdayName Function will now provoke you to apply them in your Excel spreadsheets with more productivity. You are most welcome to feel free to comment if you have any questions or queries.


Related Articles

Md. Abdur Rahim Rasel

Md. Abdur Rahim Rasel

Hi! I'm Md. Abdur Rahim Rasel. Welcome to my Profile. Currently, I am working and doing research on Microsoft Excel and here I will be posting articles related to this. I have completed my graduation in Naval Architecture and Marine Engineering(NAME) from Bangladesh University of Engineering and Technology(BUET). I have a passion for learning new things with my knowledge through perseverance and hard work.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo