VBA WEEKDAY Function (Syntax + Example) - Excel Champs
文章推薦指數: 80 %
The VBA WEEKDAY function is listed under the date category of VBA functions. When you use it in a VBA code, it returns the day number (ranging from 1 to 7) ... SkiptocontentHome➜VBATutorial➜TopVBAFunctions➜VBAWEEKDAYFunction(Syntax+Example)TheVBAWEEKDAYfunctionislistedunderthedatecategoryofVBAfunctions.WhenyouuseitinaVBAcode,itreturnsthedaynumber(rangingfrom1to7)byusingthenumberofthedayfromthesupplieddate.Insimplewords,itreturnsthenumberofthedaywithintheweek.TableofContentCloseSyntaxArgumentsExampleNotesRelatedFunctionsSyntaxWeekday(Date,[FirstDayOfWeek])ArgumentsDate:Avaliddateforwhichyouwanttogettheweekday.[FirstDayOfWeek]:Astringtodefinethefirstdayoftheweek[ThisisanoptionalargumentandifomittedVBAtakesvbSundaybydefault].vbUseSystemDayOfWeek–Asperthesystemsettings.vbSunday–SundayvbMonday–MondayvbTuesday–TuesdayvbWednesday–WednesdayvbThursday–ThursdayvbFriday–FridayExampleTopracticallyunderstandhowtouseVBAWEEKDAYfunction,youneedtogothroughthebelowexamplewherewehavewrittenavbacodebyusingit:Subexample_WEEKDAY() Range("B1").Value=Weekday(Range("A1")) EndSubIntheabovecode,wehaveusedWEEKDAYtogettheweekdayfor(Wednesday,May15,2019)thedatewhichwehaveinthecellA1andintheresult,wehave4inthecellB1.ThedayisWednesday,whichisthefourthdayoftheweek(ithastakenSundaythefirstdayoftheweek),sothatithasreturned4intheresult.NotesIfthedatespecifiedisavalueotherthanadateorastringthatcan’tberecognizedasadate,VBAwillreturntherun-time13error.RelatedFunctionsDATE|DATEADD|DATEDIFF|DATEPART|DATESERIAL|DATEVALUE|DAY|MONTH|MONTHNAME|WEEKDAYNAME|YEAR
延伸文章資訊
- 1VBA WEEKDAY Function (Syntax + Example) - Excel Champs
The VBA WEEKDAY function is listed under the date category of VBA functions. When you use it in a...
- 2MS Excel: How to use the WEEKDAY Function (WS, VBA)
The WEEKDAY function is a built-in function in Excel that is categorized as a Date/Time Function....
- 3Excel VBA Weekday Function - WallStreetMojo
The weekday function returns the provided date's day number in the week. For example, if you have...
- 4VBA WeekDay函數 - 億聚網
WeekDay WeekDay函數返回從1到7的整數,代表該日期指定星期的一天。 語法: Weekday ( date [, firstdayofweek ]) 參數說明Date, 必需的參數。
- 5Weekday 函數(Visual Basic for Applications) | Microsoft Docs
Office VBA reference topic. ... Weekday 函數語法具有下列具名引數: ... 這個範例會使用Weekday 函數從指定的日期取得一周的第幾天。