我的數據全部在一列中並向下增長。只有幾行數據,然後是空格(空格的數量有所不同)。使用空單元格作爲參數複製一系列單元格 - > PasteSpecial新工作表
我試圖選擇每組數據並將其自動轉置到下一個可用行中的下一個工作表,並繼續,直到列中沒有更多數據。
請原諒我對下面的無知,我把它拼湊在一起搜索並搜索這個網站。
這裏是我到目前爲止,這樣的作品...但我想我需要定義另一個整數,這樣我就可以得到一個範圍內進行復制,像
Sheets("Sheet1").Range(A & I 「:」 A & X).Copy
然後,similair操作粘貼:
Sheets("Sheet2").End(xlUp).Row.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
完全微距我的工作:
Sub PadOut()
Application.ScreenUpdating = False
Dim i As Integer, j As Integer
j = 1
'loops from 1 to the last filled cell in column 1 or "A"
For i = 1 To Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).row
'checks if the cell has anything in it
If IsEmpty(Sheets("Sheet1").Range("A" & i)) = False Then
'this is where the copying and pasting happens (well basically)
Sheets("Sheet1").Range(A & i).copy
Sheets("Sheet2").End(xlUp).Row).PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
j = j + 1
End If
Next i
Application.ScreenUpdating = True
End Sub
謝謝你們,我回去了,並且實際上編輯了格式,到我完成時你們都完成了。謝謝! – Krang
列「B」中是否有任何數據?如果沒有,你可以使用'CurrentRegion'屬性(如果答案是「是」,我會發佈一個答案:)) –
B列中沒有數據,我想要在列A和空白之間的空白區域他們到表2,每個數據組一行 – Krang