ไปยังเนื้อหาหลัก

วิธีนับจำนวนวันหยุดสุดสัปดาห์ / วันธรรมดาระหว่างสองวันใน Excel

บางครั้งเราจำเป็นต้องทราบว่ามีวันธรรมดากี่วันระหว่างสองวัน ตัวอย่างเช่นฉันมีสองวัน: วันที่เริ่มต้นคือ 1/1/2014 และวันที่สิ้นสุดคือ 2/15/2014 ตอนนี้ฉันต้องการทราบว่ามีวันอาทิตย์หรือวันจันทร์หรือวันอังคารกี่ครั้งในช่วงเวลานี้ อาจจะเป็นเรื่องยากสำหรับเรา แต่ที่นี่ฉันสามารถพูดคุยเกี่ยวกับวิธีการที่มีประสิทธิภาพสำหรับคุณ


นับจำนวนวันธรรมดา / วันหยุดสุดสัปดาห์ระหว่างวันที่สองวันด้วยสูตร

สมมติว่าฉันมีวันที่สองวันต่อไปนี้และฉันต้องนับว่ามีวันอาทิตย์กี่วัน เลือกเซลล์ว่างป้อนสูตรด้านล่างแล้วกด เข้าสู่ สำคัญ. และตอนนี้คุณจะได้รับจำนวนวันอาทิตย์ระหว่างสองวัน ดูภาพหน้าจอ:

=INT((WEEKDAY($C$2- 1)-$C$2+$C3)/7)

หมายเหตุ:

(1) ในสูตรข้างต้น C2 คือวันที่เริ่มต้นและ C3 ระบุวันที่สิ้นสุด

(2) ในสูตรข้างต้น 1 ย่อมาจากวันอาทิตย์ และคุณสามารถแทนที่หมายเลข 1 ด้วยตัวเลขอื่นระหว่าง 1 ถึง 7 (วันที่ 1 คือวันอาทิตย์ 2 วันจันทร์ 3 วันอังคาร 4 วันพุธ 5 วันพฤหัสบดี 6 วันศุกร์ 7 วันเสาร์)


ใช้สูตรเพื่อนับจำนวนวันทำงานเฉพาะในเดือน

บางครั้งคุณอาจต้องนับจำนวนวันทำงานทั้งหมดในเดือนนั้น ๆ บอกว่าให้นับจำนวนวันพุธทั้งหมดในเดือนกรกฎาคมปี 2020 ที่นี่ฉันจะแนะนำสูตรในการนับจำนวนวันทำงานทั้งหมดในที่ระบุ เดือนได้อย่างง่ายดาย

เลือกเซลล์ว่างพิมพ์สูตรด้านล่างแล้วกดปุ่ม Enter เพื่อรับผลการนับ

=INT((WEEKDAY(DATE(G2,G3,1)- G4)-DATE(G2,G3,1)+EOMONTH(DATE(G2,G3,1),0))/7)

หมายเหตุ / รายละเอียดเพิ่มเติม:

(1) ในสูตรข้างต้น G2 คือปีที่ระบุ G3 คือเดือนที่ระบุและ G4 คือวันที่ระบุในสัปดาห์

(2) สูตรนี้กำหนดจำนวนเต็มเพื่อแทนวันของสัปดาห์: 1 คือวันอาทิตย์ 2 คือวันจันทร์ 3 คือวันอังคาร 4 คือวันพุธ 5 คือวันพฤหัสบดี 6 คือวันศุกร์และ 7 คือวันเสาร์


ใช้ User Defined Function เพื่อนับจำนวนวันธรรมดา / วันหยุดสุดสัปดาห์ที่ระบุในเดือนนั้น ๆ

คุณยังสามารถสร้างฟังก์ชันที่กำหนดโดยผู้ใช้เพื่อคำนวณจำนวนวันธรรมดาที่ระบุในปีและเดือนที่กำหนดนอกเหนือจากสูตรข้างต้น

1. กด ALT + F11 และจะเปิดไฟล์ หน้าต่าง Microsoft Visual Basic for Applications.

2. คลิก สิ่งที่ใส่เข้าไป > โมดูลและวางรหัสต่อไปนี้ในไฟล์ หน้าต่างโมดูล.

Public Function TotalDays(pYear As Integer, pMonth As Integer, pDay As Integer)
'Update 20140210
Dim xindex As Integer
Dim endDate As Integer
endDate = Day(DateSerial(pYear, pMonth + 1, 0))
For xindex = 1 To endDate
    If Weekday(DateSerial(pYear, pMonth, xindex)) = pDay Then
        TotalDays = TotalDays + 1
    End If
Next
End Function

3. บันทึกรหัสนี้และกลับไปที่แผ่นงานจากนั้นป้อนสูตรนี้ในเซลล์ว่าง = TotalDays (ปีเดือน 1) . ในตัวอย่างนี้ฉันจะนับว่ามีวันอาทิตย์กี่วันในเดือนมิถุนายน 2020 ดังนั้นฉันจึงสามารถใช้สูตรนี้เป็นหนึ่งในสูตรด้านล่างจากนั้นกด เข้าสู่ และคุณจะได้รับกี่วันอาทิตย์ในครั้งเดียว ดูภาพหน้าจอ:

= TotalDays (C2, C3, C4)

= TotalDays (2020,6,1)

 

หมายเหตุ: สูตรนี้ใช้จำนวนเต็มเพื่อแสดงวันในสัปดาห์: วันที่ 1 คือวันอาทิตย์ 2 วันจันทร์ 3 วันอังคาร 4 วันพุธ 5 วันพฤหัสบดี 6 วันศุกร์ 7 วันเสาร์.


นับจำนวนวันหยุดสุดสัปดาห์ / วันธรรมดา / วันเฉพาะของสัปดาห์ระหว่างวันที่สองวันด้วย Kutools for Excel

จริงๆแล้วเราสามารถใช้ Kutools for Excel's จำนวนวันที่ไม่ทำงานระหว่างวันที่สองวัน สูตร, จำนวนวันทำการระหว่างวันที่สองวัน สูตรและ นับจำนวนวันทำงานที่เฉพาะเจาะจง สูตรเพื่อนับจำนวนวันหยุดสุดสัปดาห์วันหยุดสุดสัปดาห์หรือวันที่เฉพาะเจาะจงของสัปดาห์ทั้งหมดในช่วงวันที่ใน Excel ได้อย่างรวดเร็ว

Kutools สำหรับ Excel - เต็มไปด้วยเครื่องมือที่จำเป็นสำหรับ Excel มากกว่า 300 รายการ เพลิดเพลินกับฟีเจอร์ทดลองใช้ฟรี 30 วันโดยไม่ต้องใช้บัตรเครดิต! ดาวน์โหลดเดี๋ยวนี้!

1. เลือกเซลล์ว่างที่คุณจะวางผลการนับแล้วคลิก Kutools> Formula Helper> Formula Helper เพื่อเปิดใช้งานคุณสมบัตินี้

จากนั้นดำเนินการต่อตามประเภทการนับของคุณ

A. นับจำนวนวันหยุดสุดสัปดาห์ (วันเสาร์และวันอาทิตย์) ระหว่างสองวันใน Excel

ในกล่องโต้ตอบ Formulas Helper โปรดทำดังนี้:
(1) เลือก สถิติ จาก ประเภทสูตร รายการแบบหล่นลง
(2) คลิกเพื่อเลือก จำนวนวันที่ไม่ทำงานระหว่างวันที่สองวัน ใน เลือกสูตร กล่องรายการ;
(3) ป้อนวันที่เริ่มต้นในไฟล์ เริ่มวันที่ กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(4) ป้อนวันที่สิ้นสุดในไฟล์ วันที่สิ้นสุด กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(5) คลิกไฟล์ OK ปุ่ม

ตอนนี้จะส่งคืนจำนวนรวมของวันเสาร์และวันอาทิตย์ทั้งหมดในเซลล์ที่เลือก

Kutools สำหรับ Excel - เพิ่มประสิทธิภาพ Excel ด้วยเครื่องมือที่จำเป็นมากกว่า 300 รายการ เพลิดเพลินกับฟีเจอร์ทดลองใช้ฟรี 30 วันโดยไม่ต้องใช้บัตรเครดิต! Get It Now

B. นับจำนวนวันธรรมดา (ไม่รวมวันเสาร์และวันอาทิตย์) ระหว่างสองวันใน Excel

ในกล่องโต้ตอบ Formulas Helper โปรดทำดังนี้:
(1) เลือก สถิติ จาก ประเภทสูตร รายการแบบหล่นลง
(2) คลิกเพื่อเลือก จำนวนวันทำการระหว่างวันที่สองวัน ใน เลือกสูตร กล่องรายการ;
(3) ป้อนวันที่เริ่มต้นในไฟล์ เริ่มวันที่ กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(4) ป้อนวันที่สิ้นสุดในไฟล์ วันที่สิ้นสุด กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(5) คลิกไฟล์ OK ปุ่ม

จากนั้นจะส่งคืนจำนวนวันธรรมดาทั้งหมด (ไม่รวมวันเสาร์และวันอาทิตย์) ในเซลล์ที่เลือก

Kutools สำหรับ Excel - เพิ่มประสิทธิภาพ Excel ด้วยเครื่องมือที่จำเป็นมากกว่า 300 รายการ เพลิดเพลินกับฟีเจอร์ทดลองใช้ฟรี 30 วันโดยไม่ต้องใช้บัตรเครดิต! Get It Now

C. นับจำนวนวันที่ระบุในสัปดาห์ (วันจันทร์วันเสาร์วันอาทิตย์ ฯลฯ ) ระหว่างวันที่สองวันใน Excel

ในกล่องโต้ตอบ Formulas Helper โปรดทำดังนี้:
(1) เลือก สถิติ จาก ประเภทสูตร รายการแบบหล่นลง
(2) คลิกเพื่อเลือก นับจำนวนวันทำงานที่เฉพาะเจาะจง ใน เลือกสูตร กล่องรายการ;
(3) ป้อนวันที่เริ่มต้นในไฟล์ เริ่มวันที่ กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(4) ป้อนวันที่สิ้นสุดในไฟล์ วันที่สิ้นสุด กล่อง (คุณยังสามารถอ้างถึงเซลล์วันที่);
(5) ระบุวันทำงานเฉพาะด้วยจำนวนเต็ม (1 หมายถึงวันอาทิตย์ 2-5 หมายถึงวันจันทร์ถึงวันศุกร์และ 7 คือวันเสาร์)
(6) คลิกไฟล์ OK ปุ่ม

จากนั้นจะส่งกลับจำนวนรวมของวันทำงานที่ระบุในช่วงวันที่ที่กำหนด

Kutools สำหรับ Excel - เพิ่มประสิทธิภาพ Excel ด้วยเครื่องมือที่จำเป็นมากกว่า 300 รายการ เพลิดเพลินกับฟีเจอร์ทดลองใช้ฟรี 30 วันโดยไม่ต้องใช้บัตรเครดิต! Get It Now


บทความที่เกี่ยวข้อง:

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Let's say you want to calculate the 3rd Thursday of the month and assume the date of the first of the month is in cell A1. We need to first work out the date of the Thursday in the week of A1. Because Thursday is the 5th day of the week, we use: =A1-WEEKDAY(A1)+5 Then if this Thursday falls before A1, we need to add 7 using [b]((A1-WEEKDAY(A1)+5)
This comment was minimized by the moderator on the site
What about a formula that returns the actual date of the first Wed of each month, Or the 2nd and 3rd tuesday of each month? Or every 3rd tuesday? I want to be able to put in my own start and end dates and then get the actual DATES (not the count) returned to me. Any ideas?
This comment was minimized by the moderator on the site
hi sir, i want to calculate no. of weeks in excel between two dates, but Dose not see right weeks as per date for example: I enterd the date 01/01/2016 ( Friday) and second date 14/01/2016( thursday) no of weeks showing = 2 weeks. but i want to show exact 2 weeks completed 15/01/2016 other wise show previse no fo weeks.
This comment was minimized by the moderator on the site
Let the start and end dates be in cells A1 and A2, respectively. This should work: =INT((A2-A1)/7)
This comment was minimized by the moderator on the site
Is it possible to have the start date set to "=today()" and the end date, for example, the 22nd of the current cycle. As the date returns to the 23rd, refresh the formula to the following 22nd?
This comment was minimized by the moderator on the site
Assuming cycle refers to month, this should work for the end date: DATE(YEAR(TODAY()),MONTH(TODAY())+IF(DAY(TODAY())>22,1,0),22)
This comment was minimized by the moderator on the site
Why are my comments not published completely????
This comment was minimized by the moderator on the site
[quote]Why are my comments not published completely????By Mohamed[/quote] Sorry, please try to send me the formula to jaychivo#extendoffice.com. Please replace @ with #. And i will help you post it. May be there are some characters which have been blocked. :-)
This comment was minimized by the moderator on the site
Hi Jaco, You may achieve this for someone who works Mondays (2), Wednesdays (4) and Fridays (6) as follows: (1) Call the year's start and end dates [quote]StartDate[/quote] and [quote]EndDate[/quote], respectively. (2) List all the public holidays in South Africa (this could span more than one year) in a range and call it [quote]PublicHolidays[/quote] (3) To calculate the total number of days worked enter the following array formula: [quote]=INT((WEEKDAY(StartDate-2)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate )/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
Sorry the formula above is not complete: It should be: =INT((WEEKDAY(StartDate-2)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate)/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
I don't know what happened to my formula and the rest of my message above. The formula should be: =INT((WEEKDAY(StartDate-2)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate )/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
Hi, I am from South Africa and I need advice. I have two workers at work who works different days. Now I want to type in a formula in excel to count how many days a year she work (that I can do), but the trick comes in when I want to type in a formula which allows me to deduct if one of her working days is a public holiday for example she works Monday, Wednesday and Friday. That means she works 156 days per year, but I want excel to deduct the holidays if it is on one of her working days. Can someone please assist me?
This comment was minimized by the moderator on the site
Does not work properly. You need to consider what day you're starting from and ending with!
This comment was minimized by the moderator on the site
Hi Laura, Could you please elaborate?
This comment was minimized by the moderator on the site
Thank you for this. Question, how do I add another day like "Wednesday or 4" to the Monday? Basically I want it to calculate both the total of Mondays and Wednesdays between the two dates. How do I write this formula? Thanks again
This comment was minimized by the moderator on the site
To help future seekers. Use this formula for calculating days between two dates: =NETWORKDAYS.INTL( start_date, end_date, [weekend], [holidays] ) =NETWORKDAYS.INTL(A3,A4,"00000011",C3:C8) - 0=include day 1=exclude day
This comment was minimized by the moderator on the site
THANK YOU VERY MUCH!!! This is perfect! This function exactly does the task!
This comment was minimized by the moderator on the site
Try =INT((WEEKDAY($B$1-2)-$B$1+$B2)/7)+INT((WEEKDAY($B$1-4)-$B$1+$B2)/7)
This comment was minimized by the moderator on the site
Thank You. This is so useful.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations