本文介绍了用标识符将一行分成几行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的电子表格,其中包含一组数据,希望将其分成几行.

I have a large spreadsheet with a set of data I wish to split out into several rows.

格式如下:

ID A B C D

ID A B C D

这些在单独的列中,我希望它们以

These are in separate columns, and I want them to display in the format of

ID A
ID B
ID C
ID D
ID2 A
ID2 B
ID2 C
ID2 D

ID A
ID B
ID C
ID D
ID2 A
ID2 B
ID2 C
ID2 D

以此类推.我不太确定该怎么做-感谢您提供任何帮助.

And so on. I'm not really sure how I could do this - any help appreciated.

推荐答案

您可以在,并附有详细说明.

You can find both a VBA, and a formula based solution in this thread on superuser, with detailed explanations.

根据您的情况量身定制的VBA代码:

VBA code tailored to your situation:

Sub NewLayout()
    ' go over the rows
    outrow = 0
    For rowi = 1 To Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
        ' go over columns B..E
        For coli = 2 To 5
            ' for every cell: move down a row, copy id, cell value
            outrow = outrow + 1
            Cells(rowi, 1).Copy Destination:=Cells(outrow, 10)
            Cells(rowi, coli).Copy Destination:=Cells(outrow, 11)
        Next coli
    Next rowi
End Sub

这篇关于用标识符将一行分成几行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 06:24