VBA WEEKDAYNAME Function (Syntax + Example) - Excel ...

文章推薦指數: 80 %
投票人數:10人

The VBA WEEKDAYNAME function is listed under the date category of VBA functions. When you use it in a VBA code, it returns the day's (weekdays) name by ... SkiptocontentHome➜VBATutorial➜TopVBAFunctions➜VBAWEEKDAYNAMEFunction(Syntax+Example)TheVBAWEEKDAYNAMEfunctionislistedunderthedatecategoryofVBAfunctions.WhenyouuseitinaVBAcode,itreturnstheday’s(weekdays)namebyusingtheintegersuppliedasthedaynumber.Insimplewords,itreturnsthedaynameusingtheaday’snumberoftheweek(ranging1to7).TableofContentCloseSyntaxArgumentsExampleRelatedFunctionsSyntaxWeekdayName(Weekday,[Abbreviate],[FirstDayOfWeek])ArgumentsWeekday:Anintegertospecifythedayrangingfrom1to7.[Abbreviate]:Abooleanvaluetospecifyifyouneedafullnameofthemonthorabbreviatedname[ThisisanoptionalargumentandifomittedVBAtakesFALSEbydefault].UseTRUEforabbreviatedname(i.e.“Jan”,“Feb”,“Mar”,etc.)orFALSEforfullname(i.e.“January”,“February”,“March”,etc.)[FirstDayOfWeek]:Astringtodefinethefirstdayoftheweek[ThisisanoptionalargumentandifomittedVBAtakesvbSundaybydefault].vbUseSystemDayOfWeek–Asperthesystemsettings.vbSunday–SundayvbMonday–MondayvbTuesday–TuesdayvbWednesday–WednesdayvbThursday–ThursdayvbFriday–FridayvbSaturday–SaturdayExampleTopracticallyunderstandhowtouseVBAWEEKDAYNAMEfunction,youneedtogothroughthebelowexamplewherewehavewrittenavbacodebyusingit:Subexample_WEEKDAYNAME() Range("A1").Value=WeekdayName(1,"True",vbMonday) EndSubIntheabovecode,wehaveusedWEEKDAYNAMEandwehaveused1togetthefirstdayoftheweek,TRUEtogettheabbreviatedweekdayname,andvbMondaytosetMondayasthefirstdayoftheweek.Intheresult,wehaveMonincellB1.RelatedFunctionsDATE|DATEADD|DATEDIFF|DATEPART|DATESERIAL|DATEVALUE|DAY|MONTH|MONTHNAME|WEEKDAY|YEAR



請為這篇文章評分?