2014-10-31 122 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

相关问题