Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

excel - How can i copy columns to one column

Hope someone can help in coping more than 500 columns from excel to notepad in one column .. when i used the usual coping it did but beside each other. i need to copy them in one column .. i tried to search for a solution and found this forumla

=IFERROR(INDEX($A$1:$D$500,MOD(AGGREGATE(15,6,COLUMN($A$1:$SF$500)*10^6+ROW($A$1:$SF$500)/(($A$1:$SF$500<>"")),ROWS(SG$1:SG1)),10^6)-ROW($A$1)+1,AGGREGATE(15,6,COLUMN($A$1:$SF$500)/(($A$1:$SF$500<>"")),ROWS(SG$1:SG1))-COLUMN($A$1)+1),"")

but without any progress .. I'm stuck in this problems really . if there is another tool or formula i can use it to do that . I'll appreciate it .. thanks

question from:https://stackoverflow.com/questions/65908265/how-can-i-copy-columns-to-one-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this: https://www.extendoffice.com/documents/excel/4233-excel-stack-columns.html.

=INDEX(MyData,1+INT((ROW(A1)-1)/COLUMNS(MyData)),MOD(ROW(A1)-1+COLUMNS(MyData),COLUMNS(MyData))+1)

, where mydata is the range you have to insert in the column.

If you don't want to use the formula, try vba:

Function ToColumn(rng As range) As Variant
    Dim arr
    Dim cel As range
    Dim str As String

    For Each cel In rng
        If Len(cel) > 0 Then
            If str = "" Then
                str = cel
            Else
                str = str & "," & cel
            End If
        End If
    Next cel
    arr = Split(str, ",")
    ToColumn = Application.Transpose(arr)
End Function

How to use this function:

First select the range (example F1:F5) you think will fit your data, then select your range (A1:D2) you want to import in your column and type =IFERROR(ToColumn(D1:CY500),"") and press Ctrl+Shift+Enter.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...