|  

» Enter the Weekdays Mon - Fri in a Worksheet using VBA in Microsoft Excel

Question:
I want to enter the Weekdays Mon - Fri in Column A with an empty Cell following and the Date belonging to them in Column B for a pre-determined period. How can I do this with?


Answer:
Use the following Code with Excel5/7 in an English-language, with Excel8 in a general Module and run it.





Place the code below into the standard 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, "dd.mm.yy")
Cells(y, 1) = Format(i, "dddd")
ElseIf WeekDay(i, 2) = 6 Then
Else
y = y - 1
End If
Next i

End Sub



Rate This Tip
12 34 5
Rating: 2.91     Views: 14191
No comments have been submitted.
Click here to post comment
For Registered Users
Name
Comment Title
Comments