Excel - Combine multiple columns into one column

后端 未结 5 2013
忘了有多久
忘了有多久 2020-11-28 08:13

I have multiple lists that are in separate columns in excel. What I need to do is combine these columns of data into one big column. I do not care if there are duplicate ent

5条回答
  •  一向
    一向 (楼主)
    2020-11-28 09:09

    Try this. Click anywhere in your range of data and then use this macro:

    Sub CombineColumns()
    Dim rng As Range
    Dim iCol As Integer
    Dim lastCell As Integer
    
    Set rng = ActiveCell.CurrentRegion
    lastCell = rng.Columns(1).Rows.Count + 1
    
    For iCol = 2 To rng.Columns.Count
        Range(Cells(1, iCol), Cells(rng.Columns(iCol).Rows.Count, iCol)).Cut
        ActiveSheet.Paste Destination:=Cells(lastCell, 1)
        lastCell = lastCell + rng.Columns(iCol).Rows.Count
    Next iCol
    End Sub
    

提交回复
热议问题