Re: [算表] 如何把一坨數據整理成一列(VBA)
請參考以下 VBA
Sub Macro1()
Dim lastrow As Long, nextcol As Long, lastcol As Long, i As Long
Dim lastrow2 As Long
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
For i = 2 To lastcol
lastrow = Range("A" & Rows.Count).End(xlUp).Row + 1
lastrow2 = Cells(Rows.Count, i).End(xlUp).Row
Range(Cells(1, i), Cells(lastrow2, i)).Copy Cells(lastrow, 1)
Next i
For i = lastcol To 2 Step -1
Columns(i).EntireColumn.Delete
Next i
Application.ScreenUpdating = True
MsgBox ("完成")
End Sub
※ 引述《allenyang (每個女孩都有首主題曲)》之銘言:
: 軟體:Excel
: 版本:2003
: 想請問大家
: 我現在Excel有下列數據
: A B C D E F ........
: 1 a b c d e f ........
: 2 a b c d e f ........
: 3 a b c d e f ........
: 4 a b c d e f ........
: ......................
: ......................
: ......................
: ......................
: 我想要把數據全部改成一整排如下請問要怎麼操作?
: A
: 1 a
: 2 a
: 3 a
: 4 a
: ...
: ..b
: ..b
: ..b
: ..b
: ...
: ..c
: ..c
: ..c
: ..c
: ...
: ..d
: ..d
: ..d
: ..d
: ...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.131.84.234
推
07/06 19:44, , 1F
07/06 19:44, 1F
→
07/06 20:12, , 2F
07/06 20:12, 2F
※ 編輯: windknife18 來自: 61.229.90.95 (07/09 22:52)
Office 近期熱門文章
PTT數位生活區 即時熱門文章