设你的数据Sheet1,结果 放在Sheet2,执行以下宏指令:
Sub 宏1()
Dim i As Integer, j As Long, k As Long, x As Long
For i = 1 To 256 '总列数
Sheets("Sheet1").Select
x = Cells(Rows.Count, i).End(xlUp).Row '该列的行数
k = 1
For j = 1 To x
Sheets("Sheet1").Select
If Cells(j, i) <> 0 Then
Cells(j, i).Select
Selection.Copy
Sheets("Sheet2").Select
Cells(k, i).Select
ActiveSheet.Paste
k = k + 1
End If
Next
Next
End Sub