跳到主要内容

如何将列和行转置/转换为单行?

如何将多个行和列合并为单个长行? 也许这对您来说似乎很容易,因为您可以将它们一个接一个地复制并手动将它们连接成一行。 但是,如果有成百上千的行和列,将非常耗时且乏味。 在这里,我将讨论一些解决问题的快速技巧。

用公式将列和行转置/转换为单行

使用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应用程序 窗口。

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初学者来说有些困难,这里我给大家介绍一个好用的工具——Kutools for Excel。

Kutools for Excel 包括300多个便捷的Excel工具。 30天免费试用,不受限制。 立即获取

使用实用程序 变换范围 of Kutools for Excel,您可以将范围快速转换为单行,请执行以下操作:

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 Tab 为 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