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

วิธีการซ้อนคอลัมน์หลายคอลัมน์เป็นคอลัมน์เดียวใน Excel ได้อย่างรวดเร็ว?

ใน Excel ฟังก์ชัน Text to Column สามารถแบ่งเซลล์ออกเป็นหลายคอลัมน์ตามตัวคั่น แต่ถ้ามีวิธีใดในการซ้อนคอลัมน์หลายคอลัมน์เป็นคอลัมน์เดียวตามภาพด้านล่างที่แสดง? ในบทความนี้ฉันจะแนะนำเทคนิคบางอย่างในการแก้ปัญหานี้อย่างรวดเร็ว
doc stack คอลัมน์เป็นหนึ่ง 1

ซ้อนคอลัมน์หลายคอลัมน์เป็นคอลัมน์เดียวด้วยสูตร

ซ้อนคอลัมน์หลายคอลัมน์เข้าด้วยกันด้วย VBA

ซ้อนคอลัมน์หลายคอลัมน์เป็นหนึ่งเดียวด้วย Transform Range ความคิดที่ดี 3


ซ้อนคอลัมน์หลายคอลัมน์เป็นคอลัมน์เดียวด้วยสูตร

1. เลือกช่วงที่คุณต้องการวางซ้อนและไปที่ไฟล์ ชื่อ: กล่อง เพื่อตั้งชื่อช่วงนี้และกด เข้าสู่ สำคัญ. ดูภาพหน้าจอ:
doc stack คอลัมน์เป็นหนึ่ง 2

2. จากนั้นเลือกเซลล์ว่างที่คุณต้องการวางผลลัพธ์ป้อนสูตรนี้ =INDEX(MyData,1+INT((ROW(A1)-1)/COLUMNS(MyData)),MOD(ROW(A1)-1+COLUMNS(MyData),COLUMNS(MyData))+1)กด Enter และลากเติมที่จับลงจนกระทั่งข้อผิดพลาดปรากฏขึ้น ดูภาพหน้าจอ:
doc stack คอลัมน์เป็นหนึ่ง 3

ในสูตร MyData คือชื่อช่วงที่คุณระบุไว้ในขั้นตอนที่ 1

ซ้อนคอลัมน์หลายคอลัมน์เข้าด้วยกันด้วย VBA

นี่คือรหัส VBA ที่สามารถช่วยคุณได้เช่นกัน

1 กด Alt + F11 ปุ่มเพื่อแสดง Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

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

VBA: จัดเรียงคอลัมน์เป็นหนึ่ง

Sub ConvertRangeToColumn()
'UpdatebyExtendoffice
Dim Range1 As Range, Range2 As Range, Rng As Range
Dim rowIndex As Integer
xTitleId = "KutoolsforExcel"
Set Range1 = Application.Selection
Set Range1 = Application.InputBox("Source Ranges:", xTitleId, Range1.Address, Type:=8)
Set Range2 = Application.InputBox("Convert to (single cell):", xTitleId, Type:=8)
rowIndex = 0
Application.ScreenUpdating = False
For Each Rng In Range1.Rows
    Rng.Copy
    Range2.Offset(rowIndex, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
    rowIndex = rowIndex + Rng.Columns.Count
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

doc stack คอลัมน์เป็นหนึ่ง 4

3 กด F5 กุญแจสำคัญในการรันโค้ดกล่องโต้ตอบจะปรากฏขึ้นเพื่อเลือกแหล่งข้อมูลและคลิก OKเพื่อเลือกเซลล์ที่จะวางผลลัพธ์ ดูภาพหน้าจอ:
doc stack คอลัมน์เป็นหนึ่ง 5

4 คลิก OK. ตอนนี้คอลัมน์ถูกซ้อนกันในคอลัมน์เดียว
doc stack คอลัมน์เป็นหนึ่ง 6


ซ้อนคอลัมน์หลายคอลัมน์เป็นหนึ่งเดียวด้วย Transform Range

เพื่อนำไปใช้ Kutools สำหรับ Excel's ช่วงการแปลง ยูทิลิตี้ยังสามารถช่วยคุณแก้ปัญหานี้ได้อย่างรวดเร็ว

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

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

1. เลือกข้อมูลคอลัมน์ที่คุณใช้แล้วคลิก Kutools > พิสัย > ช่วงการแปลง. ดูภาพหน้าจอ:
doc stack คอลัมน์เป็นหนึ่ง 8

2 ใน ช่วงการแปลง โต้ตอบตรวจสอบ ช่วงเป็นคอลัมน์เดียว แล้วคลิก Okจากนั้นเลือกเซลล์เพื่อวางผลลัพธ์ ดูภาพหน้าจอ:
doc stack คอลัมน์เป็นหนึ่ง 9

3 คลิก OK. ตอนนี้คอลัมน์ถูกซ้อนกันเป็นคอลัมน์เดียว
doc stack คอลัมน์เป็นหนึ่ง 1

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

🤖 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 (25)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
For those looking to stack columns into one but not rows into one, you need to have a clear picture of what you really want to do.Suppose you have some 3x3 array, you want your index() function to get entries in the form of (row,column) for (1,1), (2,1), (3,1), then (1,2), (2,2), (3,2) then so on.So what you want to do is to have index() refer to a single column containing all the row numbers (1;2;3;1;2;3;1;2;3) and a single column containing all the column numbers (1;1;1;2;2;2;3;3;3).To get (1;2;3;1;2;3;1;2;3), a common programming approach is to use 1+mod(some_counter-1,3) where the mod() function gives the residuals 0,1,2,0,1,2,...
To get (1;1;1;2;2;2;3;3;3), one uses 1+int((some_counter-1)/3) where it gives 1+0, 1+0, 1+0, 1+1, 1+1, 1+1, 1+2, 1+2, 1+2
Therefore, to get a 3x3 array stacked into one, you use the formula (press Ctrl +Shft + Enter):=index( $A$1:$C$3, 1+mod(row(A1)-1,3), 1+int((row(A1)-1)/3)))where row(A1) serves as the counter as you fill your formula downwards
If you put it the other way round (row to columns, columns to row), you will get rows stacked into one column=INDEX( $A$1:$C$3, 1+INT((ROW(A1)-1)/3),1+MOD(ROW(A1)-1,3))which is essentially what the formula in this article does

In a nutshell, the formula used to stack columns in an array into a single column would be:=index( your_array_cells , 1+mod(row(A1)-1, number_of_rows_of_your_array ), 1+int((row(A1)-1)/ number_of_columns_of_your_array)))
This comment was minimized by the moderator on the site
Thank you for the formula and VBA, but neither one does what the title of the post says. I was expecting them to stack the columns, but instead they transpose each row into a column and stacks those... so it's stacking transposed rows, not columns. Still very helpful for some cases, but does anyone know how to modify the formula and/or VBA to actually stack the columns? I suppose I could transpose the entire input range then use these...
This comment was minimized by the moderator on the site
Thank you, a lot, the formula option worked very well.. your saved my lot of time.
This comment was minimized by the moderator on the site
I am using the Stack Multiple Columns Into One With Formula method and it worked perfectly, but I want it to maintain the formatting, i.e. some columns were bold & 1 was hyperlinks. Is there something that can be added to the formula to make this happen?
This comment was minimized by the moderator on the site
Hi, Susan Milard, their formula can meet your need, you can use the VBA or the Transpose Range tool,both of them can satisfy you.
This comment was minimized by the moderator on the site
I am attempting to do this over a very large table (100s of columns and rows that are all linked to formulas. My excel will keep loading and then ultimately go to not responding. Is there a way to get past this? Thanks
This comment was minimized by the moderator on the site
Hi, Tom, which method you apply does not work? The method three, transform range tool must can work.
This comment was minimized by the moderator on the site
Hi, I'm looking to go a step further with this. I've used Stack Multiple Columns Into One With VBA, code and this works. I've used Tables as the source with this code and I get the list. Is there a way to automate running the Macro? So that when I add a new entry into the table the Macro automatically runs and keeps the resulting list up to date?
This comment was minimized by the moderator on the site
Hi, Chris Blackburn, sorry I am affraid I cannot find a code can automatically run to update the result, maybe someone else can.
This comment was minimized by the moderator on the site
Hi, is there a way to make the formula ignore any blank cells your data may contain?


=INDEX(MyData,1+INT((ROW(A1)-1)/COLUMNS(MyData)),MOD(ROW(A1)-1+COLUMNS(MyData),COLUMNS(MyData))+1),


I am using a helper sheet to create a contiguous list for a data validation drop down list. Thanks in advance.
This comment was minimized by the moderator on the site
Sorry, I am not good at formula, maybe you can try to use Kutools for Excel's Select Nonblank cells utility to select the unempty cells firstly, and copy and paste them to another location, then use above methods.
This comment was minimized by the moderator on the site
I have data which ends at the same row but multiple columns in which I want them to be stacked in a sequence where B column data will go under A column data where the data ends for A column and C column data to go under A column data where the data from B column ends and so on. This way I will have data from multiple columns to fit into one column. How can I do that?
This comment was minimized by the moderator on the site
Hello , is there any to convert above data to following form ??
1
A
Lilly
2
B
Judy
...
This comment was minimized by the moderator on the site
Thanks for your leaving message, this tutorial https://www.extendoffice.com/documents/excel/5401-excel-stack-columns-into-one-column.html
is talking about how to solve this problem, you can go to view.
This comment was minimized by the moderator on the site
this is just a clickbait to have you download a paying software
This comment was minimized by the moderator on the site
The first download will be free to use in 60 days, after that, you can decide to pay for use or not.
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