跳到主要内容

如何在Excel中每隔一行拆分一列?

doc每隔1行拆分一次

例如,我有很长的数据列表,现在,我想按每隔一行将列平均分为两个列表,如下面的屏幕截图所示。 有什么好的方法可以在Excel中处理此任务?

用公式每隔一行拆分一列

用VBA代码每隔一行拆分一列

使用 Kutools for Excel 每隔一行拆分一列


箭头蓝色右气泡 用公式每隔一行拆分一列

以下公式可以帮助您快速将一列按每隔一行分成两列,请执行以下操作:

1。 例如,将此公式输入到空白单元格C2中, =INDEX($A$2:$A$13,ROWS(C$1:C1)*2-1),请看截图:

doc每隔2行拆分一次

2。 然后向下拖动填充手柄,直到错误显示在单元格中,请参见屏幕截图:

doc每隔3行拆分一次

3。 然后在单元格D2中输入另一个公式, =INDEX($A$2:$A$13,ROWS(D$1:D1)*2),然后将填充手柄向下拖动到单元格,直到出现错误值,并且列值每隔一行被分为两列,请参见屏幕截图:

doc每隔4行拆分一次


箭头蓝色右气泡 用VBA代码每隔一行拆分一列

如果您对VBA代码感兴趣,在这里,我可以为您讨论解决此问题的代码。

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下代码粘贴到 模块 窗口。

VBA代码:每隔一行将一列分为两列

Sub SplitEveryOther()
'Updateby Extendoffice
Dim Rng As Range
Dim InputRng As Range, OutRng As Range
Dim index As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
Set OutRng = OutRng.Range("A1")
num1 = 1
num2 = 1
For index = 1 To InputRng.Rows.Count
    If index Mod 2 = 1 Then
        OutRng.Cells(num1, 1).Value = InputRng.Cells(index, 1)
        num1 = num1 + 1
    Else
        OutRng.Cells(num2, 2).Value = InputRng.Cells(index, 1)
        num2 = num2 + 1
    End If
Next
End Sub	

3。 然后按 F5 键来运行此代码,然后会弹出一个提示框,提醒您选择要拆分的数据范围,请参见屏幕截图:

doc每隔5行拆分一次

4。 并点击 OK,弹出另一个提示框,让您选择要放入结果的单元格,请参见屏幕截图:

doc每隔6行拆分一次

5。 然后点击 OK,并且该列已被每隔一行分成两列。 看截图:

doc每隔7行拆分一次


箭头蓝色右气泡 使用 Kutools for Excel 每隔一行拆分一列

如果您想了解更多新事物,我可以推荐一个功能强大的工具-Kutools for Excel,其 变换范围 实用程序,您可以快速将单个行或列转换为一系列单元格,反之亦然。

Kutools for Excel : 带有300多个便捷的Excel加载项,可以在30天内免费试用

安装后 Kutools for Excel,请执行以下操作: 立即免费下载Kutools for Excel )

1。 选择要每隔一行分成两列的列数据。

2。 然后点击 库工具 > 范围 > 变换范围,请参见屏幕截图:

3。 在 变换范围 对话框中选择 单列到范围 在下面 转换类型,然后选择 固定值 并进入 2 放入盒子里 每条记录行 部分,请参见屏幕截图:

doc每隔9行拆分一次

4。 然后点击 Ok 按钮,将弹出一个提示框,提醒您选择要输出结果的单元格,请参见屏幕截图:

doc每隔10行拆分一次

5。 点击 OK,列表数据每隔一行被分为两列。

单击以了解有关此“变换范围”实用程序的更多信息。

立即免费下载Kutools for 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 (3)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How to do the opposite of this? Get two column info in one row ?
This comment was minimized by the moderator on the site
Hi, Jas,
To do the opposite of this, to convert two columns data into one single column, you should apply the below VBA code:

Sub ConvertRangeToColumn()
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

Please try, hope it can help you!
This comment was minimized by the moderator on the site
As a workaround, you can do the following: Using the above example, 1. Type "=a2" in c2 and "=a3" in d3. 2. Now select c2 through d3. 3. Drag the fill handle parallel to all the data. 4. Now delete cell a2 and shift cells up. 5. Now we need to convert the formula results to the calculated values. That's easily done by copying all the data including the blank rows and pasting the values right on top of itself. 6. Now you can simply sort any of the column alphabetically to bring all the data up.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations