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

วิธีการรวม / นับตัวเลขตัวหนาในช่วงของเซลล์ใน Excel

ผู้เขียน: Xiaoyang แก้ไขล่าสุด: 2022-05-16

เมื่อคุณมีช่วงข้อมูลที่มีตัวเลขเป็นตัวหนาในแผ่นงานและตอนนี้คุณต้องการรวมหรือนับเฉพาะเซลล์ที่เป็นตัวหนาแน่นอนว่าคุณสามารถเพิ่มทีละเซลล์ได้ด้วยตนเอง แต่จะใช้เวลานาน คุณจะรวมหรือนับเฉพาะเซลล์ตัวหนาใน Excel ด้วยวิธีที่ง่ายและรวดเร็วได้อย่างไร?

นับตัวเลขตัวหนาในช่วงด้วย User Defined Function (VBA และสูตร)
รวมตัวเลขตัวหนาในช่วงด้วย User Defined Function (VBA และสูตร)
คลิกหลายครั้งเพื่อนับและรวมเซลล์ตัวหนาในช่วงด้วย Kutools for Excel


นับตัวเลขตัวหนาในช่วงด้วย User Defined Function

ดังต่อไปนี้ ฟังก์ชันที่ผู้ใช้กำหนด สามารถช่วยให้คุณได้รับจำนวนเซลล์ที่เป็นตัวหนาอย่างรวดเร็ว กรุณาทำตามนี้:

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

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

รหัส VBA: นับตัวเลขตัวหนาในช่วงของเซลล์

Function CountBold(WorkRng As Range)
'Update 20220516
Dim Rng As Range
Dim xCount As Double
For Each Rng In WorkRng
    If Rng.Font.Bold Then
        xCount = xCount + 1
    End If
Next
CountBold = xCount
End Function

3. จากนั้นบันทึกรหัสนี้และพิมพ์สูตรนี้ = CountBold (A1: C9) ลงในเซลล์ว่างดูภาพหน้าจอ:

doc-count-bold-cells1

4. จากนั้นกด เข้าสู่ และคุณจะนับเซลล์ตัวหนาในช่วง A1: C9

doc-count-bold-cells2

หมายเหตุA1: C9 ในสูตรระบุช่วงที่คุณต้องการใช้ฟังก์ชันเพื่อนับเซลล์ตัวหนาคุณสามารถเปลี่ยนแปลงได้ตามต้องการ


รวมตัวเลขตัวหนาในช่วงด้วยฟังก์ชันที่กำหนดโดยผู้ใช้

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

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

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

รหัส VBA: รวมตัวเลขที่เป็นตัวหนาในช่วงของเซลล์

Function SumBold(WorkRng As Range)
'Update 20220516
Dim Rng As Range
Dim xSum As Double
For Each Rng In WorkRng
    If Rng.Font.Bold Then
        xSum = xSum + Rng.Value
    End If
Next
SumBold = xSum
End Function

3. จากนั้นบันทึกรหัสนี้และพิมพ์สูตรนี้ = sumbold (A1: C9) ลงในเซลล์ว่างดูภาพหน้าจอ:

doc-count-bold-cells3

4. จากนั้นกด เข้าสู่ คีย์ตัวเลขตัวหนาทั้งหมดในช่วง A1: C9 ได้รับการเพิ่มแล้ว ดูภาพหน้าจอ:

doc-count-bold-cells4

หมายเหตุA1: C9 ในสูตรระบุช่วงที่คุณต้องการใช้ฟังก์ชันเพื่อรวมเซลล์ตัวหนาคุณสามารถเปลี่ยนได้ตามต้องการ


คลิกหลายครั้งเพื่อนับและรวมเซลล์ตัวหนาในช่วงด้วย Kutools for Excel

Yคุณสามารถนับหรือรวมเซลล์ที่เป็นตัวหนาทั้งหมดในช่วงด้วยการคลิกหลาย ๆ ครั้งโดยไม่ต้องจัดการโค้ด VBA ที่ซับซ้อนและจดจำสูตร

ก่อนที่จะใช้ Kutools สำหรับ Excelโปรด ดาวน์โหลดและติดตั้งในตอนแรก.

1. สำหรับการนับเซลล์ตัวหนาโปรดเลือกเซลล์ว่างเพื่อค้นหาผลลัพธ์จากนั้นคลิก Kutools > ฟังก์ชั่น Kutools > สถิติและคณิตศาสตร์ > COUNTBYแบบอักษรตัวหนา.

และสำหรับการสรุปเซลล์ตัวหนาให้คลิก Kutools > ฟังก์ชั่น Kutools > สถิติและคณิตศาสตร์ > ซัมบีฟอนต์โบลด์. ดูภาพหน้าจอ:

2. ใน Function อาร์กิวเมนต์ กล่องโต้ตอบระบุช่วงด้วยเซลล์ตัวหนาที่คุณต้องการนับหรือรวมในกล่องอ้างอิงจากนั้นคลิกที่ไฟล์ OK ปุ่ม

ตอนนี้การนับหรือการรวมเซลล์ที่เป็นตัวหนาทั้งหมดในช่วงที่ระบุจะถูกเติมในเซลล์ที่เลือกทันที ดูภาพหน้าจอ:

  หากคุณต้องการทดลองใช้ยูทิลิตีนี้ฟรี (30 วัน) กรุณาคลิกเพื่อดาวน์โหลดแล้วไปใช้การดำเนินการตามขั้นตอนข้างต้น


รักษาค่าคงที่อ้างอิงเซลล์สูตรด้วย Kutools for Excel


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

จะระบุและเลือกเซลล์หรือข้อความที่เป็นตัวหนาทั้งหมดใน Excel ได้อย่างไร

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

🤖 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 (22)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello Anthony,
I was struggling with the same problem. For me, the solution ended up being very simple. I noticed I had 4 Modules listed. I removed all of them and then started over with the above instructions. Now it works perfectly.
This comment was minimized by the moderator on the site
I use the function and keep getting the #NAME? error. I am using Excel 365 and Windows11.
This comment was minimized by the moderator on the site
Hello, Anthony

Have you copied and pasted the code into the Module of Microsoft Visual Basic for Applications window in your worksheet? Afetr pasting the code, then, you should enter the formula as you need.

Or you can upload your file here, we can check where the problem is.

Thank you!
This comment was minimized by the moderator on the site
Ma se metto in grassetto nuove celle, la somma non si aggiorna !!!
This comment was minimized by the moderator on the site
Hello Carlo,

Gald to help. After you bold new cells, the sum won't update automatically. But when you double-click the formula cell, then press Enter, the sum will update. Please have a try.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
Hi Mandy,
thanks for your reply,
Yes I know that after double click the sum will uograde.
Is there any way to upgrade automatically the sum ?

Regards
Carlo
This comment was minimized by the moderator on the site
Hello Carlo,

Sorry that I don't have the solution for automatically upgrading the sum. The easiest way I can think of is to press Ctrl + Alt + F9 to recalculate all worksheets in all open workbooks. Have a nice day.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
А если в ячейках числа и текст? надо просуммировать только ячейки с числами жирным шрифтом.
This comment was minimized by the moderator on the site
RE: CountBold formula This formula does not appear to be dynamic. While it works at first pass, if i change the bolded cells the counters do not update unless i re-enter the formula again. Any tips?
This comment was minimized by the moderator on the site
Yea this is the same for me, otherwise it works great. But if this could be solved so it refreshes the count after each cell deselect like other basic counts it would be perfect!
This comment was minimized by the moderator on the site
Dear guys,
The formula won't update if you just change the format of the number cells.
It updates only when you change the cell content.
This comment was minimized by the moderator on the site
I'm using excel for mac 2011. How can I run the code on my system? thanks!
This comment was minimized by the moderator on the site
I copied and pasted code into excel but get #NAME? error. I made sure to enable macros and using excel 2010 version (don't know if that changes anything). Can anyone please help?!
This comment was minimized by the moderator on the site
[quote]I copied and pasted code into excel but get #NAME? error. I made sure to enable macros and using excel 2010 version (don't know if that changes anything). Can anyone please help?!By Maey[/quote] You have to follow the instruction. It says: "Click Insert > Module, and paste the following code in the Module Window", and you have to do exactly so. Make sure you paste the code in the Module Window, not in the Sheet code Window.
This comment was minimized by the moderator on the site
Thank you.. it's working...
This comment was minimized by the moderator on the site
This works a treat. I only have one issue...it doesn't seem to be adding anything after a decimal point. Any help would be greatly appreciated.
This comment was minimized by the moderator on the site
This works perfectly except it doesn't seem to add my decimal places, only adds the whole dollar. If you have a fix for this I would be very grateful.
This comment was minimized by the moderator on the site
Hi Katie, Use the below code, as the sum shows decimal places. Function SumBold(rng As Range) Dim rCell As Range Application.Volatile SumBold = 0 For Each rCell In rng If rCell.Font.Bold Then _ SumBold = SumBold + rCell Next End Function
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations