【VBA】Get the day of the week from the date

You can get
the day of the week from the date“!

Use the following function:
 Weekday Function
 WeekdayName Function

PR

VBA Code

You can get “the day of the week from the date

Option Explicit

Sub sampleProc()
    
    Dim targetDate As String
    Dim dayOfTheWeek As String
    
    'Set "Date"
    targetDate = Date
    
    'Get "the day of the week"
    dayOfTheWeek = WeekdayName(Weekday(targetDate))
    
    MsgBox (dayOfTheWeek)
    
End Sub

Set “Date“(Line 9).
※This time I’m using “Date Function”.

Get “the day of the week“(Line 12).

PR

Result

You got “the day of the week from the date“!

PR

FYI

For more information about following, see the following official online manual:

Weekday Function


WeekdayName Function

タイトルとURLをコピーしました