2016-02-26 43 views
0

作爲標題說我想要做這樣的事情。 下面我有一些數據的圖像。它總是由24行組成。 現在我想選擇每個不均勻的一個,並將其粘貼到第一列下方。我想和第二個一樣做。所以例如我想要選擇具有D列下的值的單元格,並將其粘貼在B從26開始,然後選擇F列中的單元格並將它們粘貼到我在上一步添加的單元格下面。類似於我想對C列做同樣的事情。所以E會粘貼在C,G之後...等等我有麻煩複制粘貼特定數量的細胞並粘貼到另一個

我是第一個計時器在視覺基本的Excel中,是有缺陷的。任何幫助將大大appriciated。

這是我到目前爲止的代碼:

Private Sub CommandButton21_Click() 

Dim i As Integer 
Dim j As Integer 
Dim k As Integer 
j = 26 
Dim target As Integer 
target = 2 

For k = 2 To 10 
    For i = 2 To 25 
     Cell(i, Column(k)).Select 
     Selection.Copy 
     Cell(j, Column(target)).Select 
     ActiveSheet.Paste 
     j = j + 1 
    Next i 
    k = k + 1 
Next k 

End Sub 

enter image description here

回答

1

你有寫細胞,而不是細胞,下面k個做K = K + 1 正確的代碼SI的相同的功能:

Sub CommandButton21_Click() 

Dim i As Integer 
Dim j As Integer 
Dim k As Integer 
j = 26 
Dim target As Integer 
target = 2 

For k = 2 To 3 
    For i = 2 To 26 
     Cells(i, k).Select 
     Selection.Copy 
     Cells(j, target).Select 
     ActiveSheet.Paste 
     j = j + 1 
    Next i 
Next k 

End Sub 
+0

謝謝,我注意到,當再次看我的代碼。但是,因爲這是我的問題的答案,我把它標記爲已解決。謝謝! –