2

我有 10,000 行和无限的列数据。相邻列中的两个参数在 13 个不需要的列之后重复。

我想连接由空格分隔的行的这些相邻列

例如:

连接(B2,C2,"",P2,Q2,"",AC,AD,"",....)

但我不知道数据存在于哪一列。

你能建议我一个宏,它将数据连接到一行的一个单元格中的空白列,并且前 10,000 行继续相同。非常感谢您的帮助!

4

1 回答 1

2

First off, are all the rows terminating at the same column? i.e. does every row have data in column AD but not AE?

If the answer to the above is 'yes', then you'll probably want to take a look at:

Range.End()

which is used like:

YourSheet.Range(YourRange).End(xlToRight).Column

(see here for more info)

This will return either

  • the last column with data (when the starting cell contains data)

or

  • the first column with data (when the starting cell is empty).
    • not the last column without data!

Based on your example in the question, your ranges probably start in Column B, P, AC, etc.

If the answer to the above is 'no', then you can use similar functionality, but you'll have to loop through each row...

于 2012-04-06T14:08:44.797 回答