excel vba?

2016-11-10 1:59 am
想用excel vba 整理資料,
要把一整行的資料 ,
分類成一列一列,
遇到空格則跳下行

程式碼如下,

Sub test()

Sheets(1).Select
Dim i, j, k As Integer

For i = 1 To 30

Cells(1 + i, 1).Select
Cells(1 + i, 1).Copy
Cells(1 + j, 1 + i).Select
ActiveSheet.Paste

If Cells(1 + i, 1) = "" Then
j = j + 1

End If
Next

End Sub

請問要如何修改,
才能使資料縮排。

回答 (1)

2016-11-11 8:06 am
Sub test()
j = 1
k = 3
For i = 1 To [A65536].End(xlUp).Row
If Cells(i, 1) = "" Then
j = j + 1
k = 3
Else
Cells(j, k) = Cells(i, 1)
k = k + 1
End If
Next
End Sub


收錄日期: 2021-05-03 13:49:16
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20161109175947AAgqDwS

檢視 Wayback Machine 備份