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

วิธีลบแถวและคอลัมน์ที่ว่างเปล่าออกจากตารางใน Word

คุณจะลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางใน Word ได้อย่างไร? บทช่วยสอนนี้จะแสดงหลายวิธีในการลบแถวและคอลัมน์ที่ว่างเปล่าออกจากตารางในเอกสาร Word

ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางด้วยตนเอง

ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางโดยใช้รหัส VBA

ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางได้ด้วยคลิกเดียวความคิดที่ดี 3


ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางด้วยตนเอง

Microsoft Office Word ไม่มีวิธีที่สะดวกในการลบแถวและคอลัมน์ที่ว่างเปล่าและคุณจำเป็นต้องลบออกโดยเลือกแถวและคอลัมน์ที่ว่างด้วยตนเองจากนั้นจึงลบทีละแถว

ขั้นตอนที่ 1: เลือกแถวว่างหรือคอลัมน์ว่างที่คุณต้องการลบ ดูภาพหน้าจอ:

doc-removowsandcols-1

ขั้นตอนที่ 3: ภายใต้ ตาราง เครื่องมือคลิกไฟล์ แบบ แท็บ;

doc-removowsandcols-2

ขั้นตอนที่ 4: ในไฟล์ แถวและคอลัมน์ กลุ่มคลิก ลบแถว หรือลบคอลัมน์.

doc-removowsandcols-3


ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางโดยใช้รหัส VBA

ฟังก์ชันมาโครของ Word เป็นวิธีที่สะดวกกว่ามากในการลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางในเอกสาร คุณสามารถลบแถวและคอลัมน์ว่างทั้งหมดได้ดังนี้

ขั้นตอนที่ 1: กด “ Alt-F11” เพื่อเปิดหน้าต่าง Microsoft Visual Basic for Application

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

ขั้นตอนที่ 3: จากนั้นคลิก วิ่งdoc-ย้อนกลับ-ลงชื่อ-6 เพื่อใช้ VBA

รหัส VBA เพื่อลบแถวและคอลัมน์ว่างทั้งหมดออกจากตาราง:

ย่อย DeleteEmptyTablerowsandcolumns ()
Application.ScreenUpdating = เท็จ
Dim Tbl เป็นตาราง, cel As Cell, i As Long, n As Long, fEmpty As Boolean
ด้วย ActiveDocument
สำหรับแต่ละ Tbl ในตาราง
n = Tbl.Columns.Count
สำหรับ i = n ถึง 1 ขั้นตอน -1
fEmpty = จริง
สำหรับแต่ละ cel ใน Tbl. คอลัมน์ (i) .Cells
ถ้า Len (cel.Range.Text)> 2 แล้ว
fEmpty = เท็จ
ออกสำหรับ
End If
cel ถัดไป
ถ้า fEmpty = True แล้ว Tbl.Columns (i) .Delete
ต่อไปฉัน
Tbl ถัดไป
จบด้วย
ด้วย ActiveDocument
สำหรับแต่ละ Tbl ในตาราง
n = Tbl แถวนับ
สำหรับ i = n ถึง 1 ขั้นตอน -1
fEmpty = จริง
สำหรับแต่ละ cel ใน Tbl แถว (i) .Cells
ถ้า Len (cel.Range.Text)> 2 แล้ว
fEmpty = เท็จ
ออกสำหรับ
End If
cel ถัดไป
ถ้า fEmpty = True แล้ว Tbl.Rows (i) .Delete
ต่อไปฉัน
Tbl ถัดไป
จบด้วย
ตั้งค่า cel = Nothing: ตั้งค่า Tbl = Nothing
Application.ScreenUpdating = จริง
ย่อยสิ้นสุด


ลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางได้ด้วยคลิกเดียว

Kutools for Word เป็นวิธีที่สะดวกที่สุดในการลบแถวและคอลัมน์ว่างทั้งหมดออกจากตารางในเอกสาร คุณต้องคลิกเพียงครั้งเดียวและ Kutools สำหรับ Wordของ Delete Rows/Columns ยูทิลิตี้จะลบแถวและคอลัมน์ที่ว่างทั้งหมดออกจากตารางทั้งหมดหรือตารางสำหรับคุณอย่างรวดเร็ว

Kutools สำหรับ Word, ที่มีมากกว่า  ฟังก์ชั่นที่มีประโยชน์ทำให้งานของคุณง่ายขึ้น 

หลังจากการติดตั้ง Kutools for Word โปรดทำดังนี้:(ดาวน์โหลด Kutools for Word ฟรีทันที!)

1 คลิก Kutools พลัส > Delete Rows/Columns บน Table บานหน้าต่าง

doc ลบคอลัมน์แถวว่างออกจากตาราง 1

2. จากนั้นกล่องโต้ตอบจะปรากฏขึ้นให้เลือกขอบเขตที่คุณต้องการลบตารางออกจากส่วน Look in จากนั้นเลือก แถว ตัวเลือกและ แถวว่าง ตัวเลือกหรือตรวจสอบ คอลัมน์ ตัวเลือกและ แถวว่าง ตัวเลือกตามที่คุณต้องการ หากคุณต้องการลบแถวและคอลัมน์ว่างทั้งหมดคุณต้องใช้การดำเนินการนี้สองครั้ง

doc kutools ลบแถวว่าง 2  doc kutools ลบแถวว่าง 3 

ตอนนี้กล่องโต้ตอบจะปรากฏขึ้นเพื่อเตือนให้คุณทราบว่ามีการจัดการตารางจำนวนเท่าใดให้คลิก OK เพื่อปิดและนำแถวและคอลัมน์ว่างออกจากตาราง
doc kutools ลบแถวว่าง 4

เคล็ดลับหากคุณต้องการลบแถวว่างออกจากแผ่นงาน Excel ไฟล์ ลบแถวว่าง ยูทิลิตี้ของ Kutools for Excel สามารถช่วยคุณได้

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

Kutools สำหรับ Word - ยกระดับประสบการณ์คำศัพท์ของคุณด้วย Over 100 คุณสมบัติเด่น!

🤖 Kutools ผู้ช่วย AI: แปลงโฉมงานเขียนของคุณด้วย AI - สร้างเนื้อหา  /  เขียนข้อความใหม่  /  สรุปเอกสาร  /  สอบถามข้อมูล ขึ้นอยู่กับเอกสารทั้งหมดนี้ภายใน Word

📘 ความเชี่ยวชาญด้านเอกสาร: แยกหน้า  /  ผสานเอกสาร  /  ส่งออกตัวเลือกในรูปแบบต่างๆ (PDF/TXT/DOC/HTML...)  /  แบทช์แปลงเป็น PDF  /  ส่งออกเพจเป็นรูปภาพ  /  พิมพ์หลายไฟล์พร้อมกัน...

การแก้ไขเนื้อหา: ค้นหาแบทช์และแทนที่ ข้ามหลายไฟล์  /  ปรับขนาดรูปภาพทั้งหมด  /  ย้ายแถวและคอลัมน์ของตาราง  /  แปลงตารางเป็นข้อความ...

🧹 ทำความสะอาดได้อย่างง่ายดาย: หลบไป พื้นที่พิเศษ  /  แบ่งส่วน  /  ส่วนหัวทั้งหมด  /  กล่องข้อความ  /  เชื่อมโยงหลายมิติ  / หากต้องการดูเครื่องมือถอดเพิ่มเติม โปรดไปที่ของเรา ลบกลุ่ม...

ส่วนแทรกโฆษณา: แทรก ตัวคั่นหลักพัน  /  กล่องกาเครื่องหมาย  /  ปุ่มวิทยุ  /  คิวอาร์โค้ด  /  บาร์โค้ด  /  ตารางเส้นทแยงมุม  /  คำอธิบายสมการ  /  คำบรรยายภาพ  /  คำบรรยายตาราง  /  รูปภาพหลายภาพ  / ค้นพบเพิ่มเติมใน แทรกกลุ่ม...

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

การปรับปรุงดาว: นำทางอย่างรวดเร็วไปยังสถานที่ใด ๆ  /  แทรกข้อความซ้ำอัตโนมัติ  /  สลับระหว่างหน้าต่างเอกสารได้อย่างราบรื่น  /  11 เครื่องมือการแปลง...

???? ต้องการลองใช้คุณสมบัติเหล่านี้หรือไม่? Kutools for Word มีไฟล์ ทดลองใช้ฟรี 60 วันโดยไม่มีข้อจำกัด! 🚀
 
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi
Many many thanks. Its 100% worked.
This comment was minimized by the moderator on the site
Hi, thanks for the CODE, it worked on a document with only one table.

but when launching it on a word document with different tables from different sizes, i got this error : "Run-time error '5992' Cannot access individual columns in this collection because the table has mixed cell widths"

Can anybody help, please
This comment was minimized by the moderator on the site
Bonjour,

Quand j'exécute le programme, l'erreur suivante s'affiche " Erreur de compilation : Instruction incorrecte à l'extérieur d'une procédure"

Quelqu'un a une solution s'il vous plait ?
This comment was minimized by the moderator on the site
I found this macro and it works great when it comes to a table with single empty rows.
Is it possible to change it to work on a table with split rows as well?
I would very much thank you if you have a solution for me.
This comment was minimized by the moderator on the site
Hi, shimon, I don't not understand your question, please give me examples or describe the question with more details.
This comment was minimized by the moderator on the site
You just saved me a zillion hours of frustration, THANK YOU!
This comment was minimized by the moderator on the site
u know you can just resize the table right? just filter and sort your data to top check how many rows have data, click table tools and the click resize and adjust the last number to whatever you need OR go to the bottom of the table the very last cell and use the tine blue triangle to drag and resize,
This comment was minimized by the moderator on the site
Except I have multiple page document with a table with varying information in each. Furthermore, it is a merge document so different each week. I need an automated method :)
This comment was minimized by the moderator on the site
Hi, the macro is working, BUT:

After deleting all rows, all the columns of the tables with empty rows open up very wide.

How can i fix the code so that this does not happens?


I am using Office 2016.


Thank you!
This comment was minimized by the moderator on the site
Hi All, I am looking for function in word wherein, if I remove specific word then it should remove that row as well.
This comment was minimized by the moderator on the site
Thanks for the code, really useful.
This comment was minimized by the moderator on the site
Is there a macro that will delete a row if only one of the cells in that row is empty or contains a zero?
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