2014-10-31 162 views
0
Sub sbCopyRangeToAnotherSheet() 
    Dim col As Integer 
    col = 1 
    For Each wks In Worksheets 
     If (wks.Name <> "Sheet23") Then 
      wks.Range("A1:z29").Copy Destination:=Sheets("Sheet23").Cells(1, col) 
      col = col + 25 
     End If 
    Next wks 
End Sub 

當我使用上面的代碼時,它只是將所有東西都加在一起。但我需要調換它,並將每張表單顯示在另一張下面,而不是彼此相鄰。我需要改變做什麼?轉換多張紙到一張紙上

+0

其他 – 2014-10-31 08:54:08

回答

0

試試這個,讓我知道:

Option Explicit 

Sub sbCopyRangeToAnotherSheet() 

    Dim rngRange  As Range 
    Dim rnglasRow  As Long 
    Dim wksDestination As Worksheet 
    Dim wks    As Worksheet 

    Set wksDestination = Sheets("Sheet23") 

    For Each wks In Worksheets 
     If (wks.Name <> "Sheet23") Then 
      Set rngRange = wksDestination.Cells.Find("*", wksDestination.Cells(1, 1), xlFormulas, xlWhole, xlByRows, xlPrevious) 
      If Not rngRange Is Nothing Then 
       rnglasRow = rngRange.Row 
      Else 
       rnglasRow = 1 
      End If 
      wks.Range("A1:z29").Copy Destination:=Sheets("Sheet23").Cells(rnglasRow + 2, 1) 
     End If 
    Next wks 

    'Release Memory 
    Set rngRange = Nothing 
    Set wksDestination = Nothing 
    Set wks = Nothing 

End Sub 
+0

下方顯示的每個表謝謝主席先生,我會檢查 – 2014-10-31 09:08:42

相關問題