我已经看到了这个问题的其他主题,但解决方案一直在崩溃或没有为我开始。我在Excel 2011(Mac)中工作,需要将多个列组合成一个长列。列不是都有标题,并且不是所有连续的(但如果它更容易编码,可能就是这样。)
我的专栏有时会有20,000多行,所以我尝试过的许多其他宏都会继续崩溃。
Sub MoveAllDataToColumnA()
Dim i As Long, ws As Worksheet, rngCopy As Range, rngEnd As Range
Set ws = ActiveSheet
Do Until ws.Cells(1, 2).Value = ""
Set rngCopy = ws.Range("B2", ws.Cells(ws.Rows.Count, "B").End(xlUp))
Set rngEnd = ws.Cells(ws.Rows.Count, "A").End(xlUp).Offset(1, 0)
rngEnd.Resize(rngCopy.Rows.Count, 1).Value = rngCopy.Value
rngCopy.EntireColumn.Delete
Loop
End Sub
在其他论坛上归功于ayazgreat。