How to Automatically Enter Weekdays Using VBA in Microsoft Excel 2010

In this article, you will learn how to enter weekdays i.e. Monday to Friday automatically using VBA code in any column.
Click on Developer tab

From Code group select Visual Basic
Click on Insert, and then Module
This will create new module.

Enter the following code in the Module
Sub WeekendOut()

Dim Start As Date, Off As Date

Dim y%, i#

    Start = InputBox("Start Date:")

    Off = InputBox("End Date:")


    For i = Start To Off

        y = y + 1

        If Weekday(i, 2) < 6 Then

            Cells(y, 2) = Format(i, "mm-dd-yy")

            Cells(y, 1) = Format(i, "dddd")

        ElseIf Weekday(i, 2) = 6 Then


            y = y - 1

        End If

    Next i

End Sub

Press ALT + F8 shortcut key for opening Macro window, and then select the macro.
Alternatively, you can press F5 to run the code in VBA screen.

After executing the macro, we will get the following input box

We require to enter Start Date in MM/DD/YYYY format
Then the code will ask to input the End Date

Hence, we will get the day of week in column A & the next cell will store the date.

In this way, you can easily enter the weekdays without taking any manual pain.


Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.