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

วิธีเชื่อมโยงช่องทำเครื่องหมายกับเซลล์หลายเซลล์ใน Excel

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

เชื่อมโยงช่องทำเครื่องหมายกับเซลล์หลายเซลล์ด้วยสูตรทีละเซลล์

เชื่อมโยงช่องทำเครื่องหมายกับหลายเซลล์พร้อมกันด้วยรหัส VBA


ลูกศรสีฟ้าฟองขวา เชื่อมโยงช่องทำเครื่องหมายกับเซลล์หลายเซลล์ด้วยสูตรทีละเซลล์

ในการเชื่อมโยงช่องทำเครื่องหมายกับเซลล์ใดเซลล์หนึ่งคุณสามารถใช้สูตรง่ายๆเพื่อเชื่อมโยงด้วยตนเอง

1. หลังจากใส่ช่องทำเครื่องหมายในแผ่นงานของคุณแล้วหากต้องการเลือกช่องทำเครื่องหมายโปรดกด Ctrl จากนั้นคลิกช่องทำเครื่องหมายแรกที่คุณต้องการเชื่อมโยงไปยังเซลล์อื่น

2. จากนั้นในแถบสูตรพิมพ์เครื่องหมายเท่ากับ =จากนั้นคลิกเซลล์หนึ่งเซลล์ที่คุณต้องการเชื่อมโยงช่องทำเครื่องหมายเช่น B2 ดูภาพหน้าจอ:

doc-link-หลายช่องทำเครื่องหมาย-1

3. จากนั้นกด เข้าสู่ บนแป้นพิมพ์ตอนนี้เมื่อคุณทำเครื่องหมายในช่องนี้เซลล์ที่เชื่อมโยงจะแสดงขึ้น TRUEหากยกเลิกการเลือกระบบจะแสดง FALSEดูภาพหน้าจอ:

doc-link-หลายช่องทำเครื่องหมาย-2

4. ทำตามขั้นตอนข้างต้นซ้ำเพื่อเชื่อมโยงช่องทำเครื่องหมายอื่น ๆ ทีละช่อง


ลูกศรสีฟ้าฟองขวา เชื่อมโยงช่องทำเครื่องหมายกับหลายเซลล์พร้อมกันด้วยรหัส VBA

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

1. ไปที่แผ่นงานของคุณพร้อมกับรายการช่องทำเครื่องหมาย

2. กด ALT + F11 คีย์เพื่อเปิด หน้าต่าง Microsoft Visual Basic for Applications.

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

รหัส VBA: เชื่อมโยงช่องทำเครื่องหมายไปยังเซลล์หลายเซลล์พร้อมกัน

Sub LinkChecks()
'Update by Extendoffice
Dim xCB
Dim xCChar
i = 2
xCChar = "B"
For Each xCB In ActiveSheet.CheckBoxes
If xCB.Value = 1 Then
    Cells(i, xCChar).Value = True
Else
    Cells(i, xCChar).Value = False
End If
xCB.LinkedCell = Cells(i, xCChar).Address
i = i + 1
Next xCB
End Sub

4. จากนั้นกด F5 คีย์เพื่อเรียกใช้รหัสนี้ช่องทำเครื่องหมายทั้งหมดในแผ่นงานที่ใช้งานได้ถูกเชื่อมโยงกับเซลล์เมื่อคุณเลือกช่องทำเครื่องหมายเซลล์สัมพัทธ์จะแสดง TRUEถ้าคุณล้างกล่องกาเครื่องหมายเซลล์ที่เชื่อมโยงจะแสดงขึ้น FALSEดูภาพหน้าจอ:

doc-link-หลายช่องทำเครื่องหมาย-3

หมายเหตุ: ในโค้ดด้านบน i = 2, จำนวน 2 คือแถวเริ่มต้นของช่องทำเครื่องหมายและตัวอักษร B คือตำแหน่งคอลัมน์ที่คุณต้องการเชื่อมโยงช่องทำเครื่องหมาย คุณสามารถเปลี่ยนได้ตามความต้องการของคุณ


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

วิธีเลือกช่องทำเครื่องหมายทั้งหมดโดยใช้ช่องทำเครื่องหมายเดียวใน Excel

วิธีแทรกช่องทำเครื่องหมายหลายช่องใน 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 (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Will this work when I try to sort Alphabetically? I've found that when I sort from A-Z, the check boxes do not follow the cells they were originally next to. Will your method help? Thank you!
This comment was minimized by the moderator on the site
My problem is: I am creating a to do list with daily habits. I want to be able to make statistics from it using the true and false from checking the box linked to a cell but do not want to individually do it, but when i use the code nothing happens?
This comment was minimized by the moderator on the site
Hello, Gregor,
The VBA code works well in my workbook.
You can upload your file here, so that we can check where the problem is.
Thank you!
This comment was minimized by the moderator on the site
Здравствуйте.
Подскажите. Возможно ли суммирование чисел в ячейках по установке флажка?

https://drive.google.com/file/d/1qmEnngPDdgWTISJETJ44IkxG-MABfqhh/view?usp=sharing[/img][/b][/u][/b

В ячейке F3 скрыто число 2 а в ячейке G3 скрыто число 0,3, можно ли сделать так чтоб при установки галочки в ячейке Q3 вычислялась сумма.
Сумма вычислений только на строку в диапазоне F3-P3
This comment was minimized by the moderator on the site
great thread and it works for me.
BUT, I need to save the TRUE/FALSE data to another sheet. What is the VBA to save it to another sheet other than the active one?
This comment was minimized by the moderator on the site
How about if you have some empty rows in ColumnA (as per your example) in between checkboxes? Using the above code it gets the linked cells wrong if there are empty rows because it does not skip them. Interested to see the solution
This comment was minimized by the moderator on the site
Did u find any solution for this? Same problem
This comment was minimized by the moderator on the site
Sub LinkCheckBoxes()

Dim chk As CheckBox

Dim lCol As Long

lCol = 1 'number of columns to the right for link



For Each chk In ActiveSheet.CheckBoxes

With chk

.LinkedCell = _

.TopLeftCell.Offset(0, lCol).Address

End With

Next chk



End Sub
This comment was minimized by the moderator on the site
Hello! Nice post about the VBA... but what if there are 3 columns that has checkboxes that needs to be linked in three other columns as well? Let's say columns B, C, and D has checkboxes and should be linked to columns H, I, and J respectively.
This comment was minimized by the moderator on the site
Hi, Having same problem - Have you found out how to get around this? Thanks, Paul
This comment was minimized by the moderator on the site
Hey,

Try this:

Sub LinkCheckBoxes()
Dim chk As CheckBox
Dim lCol As Long
lCol = 2 'number of columns to the right for link

For Each chk In ActiveSheet.CheckBoxes
With chk
.LinkedCell = _
.TopLeftCell.Offset(0, lCol).Address
End With
Next chk

End Sub



If you have for example, checkboxes in D,E,F change "Icol" to 1, so it links to G,H and I, respectively.
This comment was minimized by the moderator on the site
Hi, I have the same issue but did not work for me, can you help please.Thanks
This comment was minimized by the moderator on the site
thank you very much
This comment was minimized by the moderator on the site
Can you help me out with this same problem?
This comment was minimized by the moderator on the site
Can I do this and program the boxes to say something other than true and false?
This comment was minimized by the moderator on the site
Hi, In your VBA code: link checkboxes to multiple cells at once, the code is set up to link the cell below it. How is the code if I want to link the cell to the left of the first one? Thanks!
This comment was minimized by the moderator on the site
i have more than 40000 cell which have checkbox. when i use this code, it takes more than 5 second to process, i define different macros for different cells but i have still the problem, what can i do?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations