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

วิธีการเชื่อมต่อเซลล์โดยไม่สนใจหรือข้ามช่องว่างใน Excel

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

เซลล์ที่เชื่อมต่อกันไม่สนใจหรือข้ามช่องว่างด้วยสูตร

เซลล์ที่เชื่อมต่อกันละเว้นหรือข้ามช่องว่างด้วย User Defined Function

เซลล์ที่เชื่อมต่อกันละเว้นหรือข้ามช่องว่างด้วย Kutools for Excel


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

doc รวมช่องว่างการข้าม 1

โปรดป้อนสูตรนี้ลงในเซลล์ว่างที่คุณต้องการใส่ผลลัพธ์ที่ต่อกัน =A1&IF(A2<>"","-"&A2,"")&IF(A3<>"","-"&A3,"")&IF(A4<>"","-"&A4,"")&IF(A5<>"","-"&A5,"")จากนั้นลากที่จับเติมไปทางขวาไปยังเซลล์ที่คุณต้องการใช้สูตรนี้และค่าของแถวจะถูกรวมเข้าด้วยกันโดยไม่มีเซลล์ว่างดังภาพหน้าจอต่อไปนี้:

doc รวมช่องว่างการข้าม 2

เคล็ดลับ: หากจำเป็นต้องต่อแถวเพิ่มเติมคุณควรใช้ฟังก์ชัน IF เพื่อเข้าร่วมเซลล์เช่น =A1&IF(A2<>"","-"&A2,"")&IF(A3<>"","-"&A3,"")&IF(A4<>"","-"&A4,"")&IF(A5<>"","-"&A5,"")&IF(A6<>"","-"&A6,""). "-" อักขระในสูตรสามารถแทนที่ด้วยตัวคั่นอื่น ๆ ที่คุณต้องการได้


เชื่อมต่อเซลล์หลายเซลล์โดยไม่สนใจหรือข้ามช่องว่าง:

Kutools สำหรับ Excel's รวมกัน แถวคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล คุณลักษณะนี้สามารถช่วยให้คุณรวมหรือเชื่อมต่อแถวคอลัมน์หรือเซลล์หลาย ๆ แถวโดยไม่สูญเสียข้อมูล แต่ข้ามหรือละเว้นเซลล์ว่าง คลิกเพื่อดาวน์โหลด Kutools for Excel!

doc รวมช่องว่างการข้าม 7

Kutools สำหรับ Excel: ด้วย Add-in ของ Excel ที่มีประโยชน์มากกว่า 300 รายการให้ทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน ดาวน์โหลดและทดลองใช้ฟรีทันที!


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

1. กด Alt + F11 ใน Excel และจะเปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

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

รหัส VBA: เซลล์ที่เชื่อมต่อกันละเว้นช่องว่าง:

Function Concatenatecells(ConcatArea As Range) As String
'updateby Extendoffice
  For Each n In ConcatArea: nn = IIf(n = "", nn & "", nn & n & "/"): Next
  Concatenatecells = Left(nn, Len(nn) - 1)
End Function

3. บันทึกและปิดหน้าต่างรหัสนี้กลับไปที่แผ่นงานจากนั้นป้อนสูตรนี้: = concatenatecells (A1: A5) ลงในเซลล์ว่างแล้วลากที่จับเติมไปทางขวาของเซลล์เพื่อใช้สูตรนี้และคุณจะได้ผลลัพธ์ดังต่อไปนี้:

doc รวมช่องว่างการข้าม 3

เคล็ดลับ: ในโค้ด VBA ด้านบนคุณสามารถเปลี่ยน "/” ไปยังตัวคั่นอื่น ๆ ที่คุณต้องการ


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

Kutools สำหรับ Excel : ด้วย Add-in ของ Excel ที่มีประโยชน์มากกว่า 300 รายการทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน

หลังจากการติดตั้ง Kutools สำหรับ Excelโปรดดำเนินการดังนี้:

1. เลือกค่าเซลล์ที่คุณต้องการรวม

2. คลิก Kutools > ผสานและแยกรวมแถวคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูลดูภาพหน้าจอ:

3. ในกล่องโต้ตอบที่โผล่ออกมา:

  • (1. ) เลือกประเภทของเซลล์ที่คุณต้องการรวมคุณสามารถรวมคอลัมน์รวมแถวและรวมเซลล์ทั้งหมดเป็นเซลล์เดี่ยว
  • (2. ) ระบุตัวคั่นสำหรับเนื้อหาที่ต่อกันของคุณ
  • (3. ) เลือกตำแหน่งที่จะใส่ผลลัพธ์คุณสามารถใส่ผลลัพธ์ไปยังเซลล์บนสุดหรือเซลล์ล่างสุด
  • (4. ) ระบุวิธีจัดการกับเซลล์ที่รวมกันคุณสามารถเก็บหรือลบเนื้อหาจากเซลล์ที่รวมกันเหล่านั้นและคุณยังสามารถผสานเซลล์ที่รวมเข้าด้วยกันได้

doc รวมช่องว่างการข้าม 5

4. หลังจากเสร็จสิ้นการตั้งค่าคลิก Ok และแถวที่เลือกได้รวมกันเป็นเซลล์เดียวแยกกันและได้ข้ามช่องว่างโดยอัตโนมัติดูภาพหน้าจอ:

doc รวมช่องว่างการข้าม 6

ดาวน์โหลดและทดลองใช้ Kutools for Excel ฟรีทันที!


Kutools สำหรับ Excel: ด้วย Add-in ของ Excel ที่มีประโยชน์มากกว่า 300 รายการให้ทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน ดาวน์โหลดและทดลองใช้ฟรีทันที!

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

🤖 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 (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How would you change the "/" sign for CHAR(10) or line break?
This comment was minimized by the moderator on the site
Hello, Alan,To combine the cells with the line break, you can apply the below simple formula:=TEXTJOIN(CHAR(10),TRUE,A1:A5)
After getting the results with this formula, you should click the Wrap Text to get the correct results you need.
Please try, thank you!
This comment was minimized by the moderator on the site
super, thank Q
This comment was minimized by the moderator on the site
I had issues with the formula provided causing leading delimiters, so I did this instead and it works well. This is concatenating cells horizontally while ignoring blank cells and results in no extra commas.

=IF(A2="", "", A2)&IF(A2="", "", ", ")&IF(B2="", "", B2)&IF(B2="", "", ", ")&IF(C2="", "", C2)
This comment was minimized by the moderator on the site
This worked a treat, thanks so much
This comment was minimized by the moderator on the site
Hi, used the macro and changed the "/" to a comma "," but got a lot of commas and it appeared to add all the blank cells.
I am doing a nested if statement to determine the appropriate sorting in the database. Is this enough to make the blank cell 'active' so that the macro sees this and adds it to the text string? How to work around that?
thanks much
This comment was minimized by the moderator on the site
Hello, Melinda,
the above vba code works well in my worksheet, you just need to change the separator / to comma as below:

Function Concatenatecells(ConcatArea As Range) As String
'updateby Extendoffice 20151103
For Each n In ConcatArea: nn = IIf(n = "", nn & "", nn & n & ","): Next
Concatenatecells = Left(nn, Len(nn) - 1)
End Function

and then apply this formula:=concatenatecells(A1:A5)
This comment was minimized by the moderator on the site
thanks!
I found my problem was in the logic statement that I used to select data for these cells that I was trying to text string. I used a " " instead of "" for the false statement. That was picked up by the macro and used as a space bar and came out , , , , , text, , , ,
So I went back and took out the space and just have the "" and then the macro worked great.
Of course I am learning macros so that's another adventure.
thanks much!!
This comment was minimized by the moderator on the site
Thank you, it was very helpful!
This comment was minimized by the moderator on the site
Please help, i dont always have a value in my first column, that couses that I end up with a seperator infort of the final result. Is there a way around this?
This comment was minimized by the moderator on the site
ever get tis figured out? same boat.
This comment was minimized by the moderator on the site
I don't know how to do it all in one cell, but I added a row with this formula: =IF(LEFT(U20,1)=",",RIGHT(U20,LEN(U20)-2),U20).
My separator was a comma and a space ", " so I used -2 for LEN. U20 is the cell with the concatenated &if formula. The logic of this formula is that if the first character from the left equals a comma, then delete the first two characters; otherwise leave it alone.

Hope this helps.
This comment was minimized by the moderator on the site
Thank you! This saved hours of frustration on my part! Works as a charm!
This comment was minimized by the moderator on the site
The VBA script is wrong, because the output of the formula puts a huge space between the delimiters.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations