Excel 合并列

发布于 2024-09-28 10:57:04 字数 219 浏览 0 评论 0原文

大家好,我想合并到 Excel 2003 中的列。

例如:

Col1    Col2
------------
1       5
3       4
4       6
7       6

合并的列应如下所示:

Col3
----
1
3
4
4
5
6
6
7

谢谢!

Hi all I want to merge to columns in excel 2003.

For example:

Col1    Col2
------------
1       5
3       4
4       6
7       6

The merged column should look like this:

Col3
----
1
3
4
4
5
6
6
7

Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵你的手,一向走下去 2024-10-05 10:57:04

假设您的 Col1Col2Col3 是列 ABC,可以使用makro:

Range("A1:" & Range("A65536").End(xlUp).Address).Select
Selection.Copy

Range("C1").Select
ActiveSheet.Paste

Range("B1:" & Range("B65536").End(xlUp).Address).Offset(1, 0).Select
Selection.Copy

Range("C65536").End(xlUp).Select
ActiveSheet.Paste

来源:链接

Assuming, that your Col1, Col2 and Col3 are Columns A, B and C, you can use makro:

Range("A1:" & Range("A65536").End(xlUp).Address).Select
Selection.Copy

Range("C1").Select
ActiveSheet.Paste

Range("B1:" & Range("B65536").End(xlUp).Address).Offset(1, 0).Select
Selection.Copy

Range("C65536").End(xlUp).Select
ActiveSheet.Paste

Source: link

那伤。 2024-10-05 10:57:04

尽管您可以轻松地使用 Excel 的内置函数将每列中的值复制并粘贴到第三列中,但您没有说明是否需要对 Col3 中的结果进行排序,或者是否应删除重复值或不。如果是这样,您可能需要在 Excel VBA 中编写用户定义函数(相当于 Excel 宏)才能执行此操作。

您的解决方案可能如下所示(伪代码):

  • 迭代 Col1 中的所有行并将值存储在数组中
  • 迭代 Col2 中的所有行并将值存储在第二个数组中
  • 创建一个新数组并合并其他两个数组中的值
  • 将组合数组中的值输出到 Col3

您的函数/宏可能需要接受三个输入参数,它们是两个源列和输出列的范围。

Although you could easily use Excel's built-in functions to copy and paste the values from each column into the third column, you don't state if it's a requirement that the results in Col3 need to be sorted, or whether duplicate values should be removed or not. If so, you might have to write a user-defined function (equivalent to an Excel macro) in Excel VBA to do this.

Your solution might look like this (pseudo-code):

  • Iterate through all rows in Col1 and store values in an array
  • Iterate through all rows in Col2 and store values in a second array
  • Create a new array and combine the values from the other two arrays
  • Output the values from the combined array into Col3

Your function/macro will probably need to accept three input parameters which would be the ranges of the two source columns and the output column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文