跳到主要內容

如何將列和行轉置/轉換為單行?

如何將多個行和列合併為一個長行? 也許這對您來說似乎很容易,因為您可以將它們一個接一個地複制並手動將它們連接成一行。 但是,如果有成百上千的行和列,將非常耗時且乏味。 在這裡,我將討論一些解決問題的快速技巧。

用公式將列和行轉置/轉換為單行

使用VBA代碼將列和行轉置/轉換為單行

使用Kutools for Excel將列和行轉置/轉換為單行


箭頭藍色右氣泡 用公式將列和行轉置/轉換為單行

假設您具有一系列數據,如下面的屏幕快照所示,則可以在具有長公式的新工作表中將範圍數據轉換為一行。

doc轉換範圍到行1

請按以下方式應用公式:

1.在活動工作簿的新工作表中,單擊單元格A1,複製並粘貼以下公式: =OFFSET(Sheet1!$A$1,((ROW()-1)*5)+(FLOOR(COLUMN()-1,4)/4),(COLUMN()-1)-(FLOOR(COLUMN()-1,4)))

備註: Sheet1!$ A $ 1 是您要使用的工作表和範圍引用。

ROW()-1)* 5 在上式中 5 代表行號; 和 欄()-1,4)/ 4是, 4 代表列號。 您可以根據需要更改它們。

2.然後將填充手柄向右拖動,直到出現數字0。 在這種情況下,該範圍中的所有數據都已被換入新工作表中的一行中。 看截圖:

doc轉換範圍到行2


箭頭藍色右氣泡 使用VBA代碼將列和行轉置/轉換為單行

以下VBA代碼還可以幫助您將一系列數據轉換為一行。

1.按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊 窗口。

Sub TransformOneRow()
'Updateby20131120
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Ranges to be transform :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Paste to (single cell):", xTitleId, Type:=8)
Application.ScreenUpdating = False
xRows = InputRng.Rows.Count
xCols = InputRng.Columns.Count
For i = 1 To xRows
    InputRng.Rows(i).Copy OutRng
    Set OutRng = OutRng.Offset(0, xCols + 0)
Next
Application.ScreenUpdating = True
End Sub

3.然後按 F5 鍵以運行代碼,會彈出一個對話框供您選擇要轉換為行的內容範圍,然後單擊 Ok,另一個彈出對話框供您選擇單個單元格以顯示結果。 查看屏幕截圖:

然後單擊 Ok,所選範圍內的內容將轉換為一行。 看截圖:

備註:在 設置OutRng = OutRng.Offset(0,xCols + 0),您可以更改 0 可以滿足您的需求。

例如,如果您想將累積到原始行的結果用一列分開,則可以更改 設置OutRng = OutRng.Offset(0,xCols + 0)設置OutRng = OutRng.Offset(0,xCols + 1),結果如下所示:


箭頭藍色右氣泡 使用Kutools for Excel將列和行轉置/轉換為單行

對於我們Excel初學者來說,以上兩種方法似乎有些困難,在這裡,我將為您介紹一個方便的工具-Excel的Kutools。

Excel的Kutools 包括300多個便捷的Excel工具。 30天免費試用,不受限制。 立即獲取

使用實用程序 變換範圍 of Excel的Kutools,您可以將範圍快速轉換為單行,請執行以下操作:

1.選擇要移調的範圍。

2。 點擊 庫工具 > 範圍轉換器 > 變換範圍,請參見屏幕截圖:

doc轉換範圍到行4

3。 在裡面 變換範圍 對話框中選擇 範圍到單行 選項,請參見屏幕截圖:

doc轉換範圍到行5

4。 然後點擊 OK,然後單擊一個單元格以將結果放入彈出框。

doc轉換範圍到行6

5。 點擊 OK,並且範圍內的數據已轉置為一行。 查看屏幕截圖:

doc轉換範圍到行1
-1
doc轉換範圍到行7

如果您想進一步了解此功能,請訪問 變換範圍.


相關文章:

如何在Excel中將行更改為列?

如何在Excel中將單個列轉置/轉換為多個列?

如何將列和行轉置/轉換為單列?

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have the following data set.
2 0.350563636 0.846454545 1.927818182 2.288090909 19.13436364 39.82727273 3.307545455
3 38.12 38.53636364 32.42454545 1790.618182 70.78181818 99.81181818 71.4 7.95E-05 0.000110545
4 0.765436364 0.905981818 5.759181818 43.40363636 2.136818182
in excel.
I want to convert in to single row side by side like as follow:


2 0.350563636 0.846454545 1.927818182 2.288090909 19.13436364 39.82727273 3.307545455 3 38.12 38.53636364 32.42454545 1790.618182 70.78181818 99.81181818 71.4 7.95E-05 0.000110545 4 0.765436364 0.905981818 5.759181818 43.40363636 2.136818182


How is it possible?
Thanks
This comment was minimized by the moderator on the site
From:

A B C
E F G
H I J



To:

A B C E F G H I J

How to change from above to single row?
This comment was minimized by the moderator on the site
Have you been able to accomplish this? I'm having the same problem.
This comment was minimized by the moderator on the site
Hello, i would to know how to convert 10 rows in excel into 10 different pdf's (or) word document in java coding. Thank you
This comment was minimized by the moderator on the site
Transform range in Kutools did not work. Waste of time. Install de-installed my ASAP utilities WITHOUT permission. Total B.S.
This comment was minimized by the moderator on the site
i want to convert following word table pf 250 basic 3000 da 2000 wa 100 hra 1500 oa 300 into pf wa basic hra da oa 250 100 3000 1500 2000 300 can anyone help me
This comment was minimized by the moderator on the site
I need to convert the following type data to a single row as mentioned last; ----------------------------------------------------------------------------------------------------------------------------------------------------------- A B C D E F G H ----------------------------------------------------------------------------------------------------------------------------------------------------------- Sl.No. - Mem.No. - Name & Address - Parents Name - Qualification - Occupation - Present Address - Remarks ----------------------------------------------------------------------------------------------------------------------------------------------------------- 1 103 Rajesh Govind BA Welder Rajesh G X KayGee Villa Dubai AN Apartments Kastur Marg RN Street Coimbatore Bangaluru Tamil Nadu Karnataka 2 104 Ganesh 1 - 103 - Rajesh - KayGee Villa - Kastur Marg - Coimbatore - Tamil Nadu - Govind - - - - BA - - - - Welder - Dubai - - - - Rajesh G - AN Apartments - RN Street - Bangaluru - Karnataka - X 2 - 104 - Ganesh - ................................................
This comment was minimized by the moderator on the site
I tried the above formula: =OFFSET(Sheet1!$A$1,((ROW()-1)*5)+(FLOOR(COLUMN()-1,4)/4),(COLUMN()-1)-(FLOOR(COLUMN()-1,4))) but all it does is place the value from sheet1 A1 in all of the columns. Why won't it display the other data? Example: 1 2 3 4 5 6 7 8 9 1 2 3 Becomes this after adding your formula: 1 1 1 1 1 1 1 1 1 1 1 1
This comment was minimized by the moderator on the site
ABC TRAVELS KING'S ST. KANDY 081-9999999 DEF TRAVELS KING'S ST. KANDY 081-8888888 -- -- about 500 travels like in same row as above, and there is blank row in between each travel data. I would like to have this as following in easy way. column A Column B Column C ABC TRAVELS KING'S ST. KANDY 081-9999999 DEF TRAVELS KING'S ST. KANDY 081-8888888 --- Please help
This comment was minimized by the moderator on the site
I have a fix range in sheet1 like (D8:F14). How to transpose it to sheet2 fixed row like (C3:W3)? Thanks for your response.
This comment was minimized by the moderator on the site
Could you please help me to transpose / convert single row (wrap text) into rows? Thanks in advance!!!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations