2014-10-14 2 views
-1

내가 모두 내 과제에 대한 여러 워크 시트의 요약 데이터를 만들고 싶어, VBA의 noobs에 야에 여러 워크 시트에서 데이터의 행을 당겨, 그래서 여기엑셀 - 나는 여러 웹에서 무엇을 얻을 VBA, 요약 워크 시트

..입니다 그것이 작동하지 않는 이유는 워크 시트의 요약 워크 시트 늘 사본 등 VBA, ISO-1L의 데이터에 익숙하지 않아요으로
Sub AddSummaryData() 
    Dim Sh As Worksheet 
    Dim Newsh As Worksheet 
    Dim myCell As Range 
    Dim ColNum As Integer 
    Dim Num As Integer 
    Dim RwNum As Long 
    Dim Basebook As Workbook 

    With Application 
     .Calculation = xlCalculationManual 
     .ScreenUpdating = False 
    End With 

    Set Basebook = ThisWorkbook 
    Set Newsh = Basebook.Worksheets("Summary") 
    Newsh.Rows("14:27").ClearContents 

    'The links to the first sheet will start in row 10 
    RwNum = 10 

    'Setting the Number 
    Num = 0 

    For Each Sh In Basebook.Worksheets 
     If Sh.Name <> "Main" And Sh.Name <> "Input and Basis" And Sh.Name <> "Template" And Sh.Name <> "Summary" And Sh.Visible Then 
      ColNum = 4 
      RwNum = RwNum + 4 
      Num = Num + 1 
      'add number 
      Newsh.Cells(RwNum, 1).Value = Num 
      'Copy the sheet name in the A column 
      Newsh.Cells(RwNum, 2).Value = Sh.Name 

      For Each myCell In Sh.Range("A16,B16,F16") '<--Change the range 
      Newsh.Cells(RwNum, 4).Value = Sh.Range("E13") 


       ColNum = ColNum + 2 
       Newsh.Cells(RwNum, ColNum).Formula = _ 
       "='" & Sh.Name & "'!" & myCell.Address(False, False) 
      Next myCell 

      For Each myCell In Sh.Range("A17,B17,F17") '<--Change the range 

       Newsh.Cells(RwNum + 1, ColNum).Formula = _ 
       "='" & Sh.Name & "'!" & myCell.Address(False, False) 
      Next myCell 

      For Each myCell In Sh.Range("A18,B18,F18") '<--Change the range 

       Newsh.Cells(RwNum + 2, ColNum).Formula = _ 
       "='" & Sh.Name & "'!" & myCell.Address(False, False) 
      Next myCell 

      For Each myCell In Sh.Range("A19,B19,F19") '<--Change the range 

       Newsh.Cells(RwNum + 3, ColNum).Formula = _ 
       "='" & Sh.Name & "'!" & myCell.Address(False, False) 

      Next myCell 

     End If 
    Next Sh 

    'Opening Summary Sheet 
    With Sheets("Summary") 
     .Select 
    End With 

    Newsh.UsedRange.Columns.AutoFit 

    With Application 
     .Calculation = xlCalculationAutomatic 
     .ScreenUpdating = True 
    End With 
End Sub 

내가 이해하지 못하는 녹색 강조에 ..

이미지 :

Sample image

+0

을 신경 쓰지? 두 번째로 ISO-1L과 다른 시트가 보이거나 숨겨져 있습니까? –

+0

다른 시트가 보입니다. 두 번째로, 어제는 어떤 줄이 잘못 표시되는지 알지 못합니다 ... – kireta7

답변

0

..`의 이미 해결, 그것은 오류를주고있다 '선

For Each Sh In Basebook.Worksheets 
    If Sh.Name <> "Main" And Sh.Name <> "Input and Basis" And Sh.Name <> "Template" And Sh.Name <> "Summary" And Sh.Visible Then 
     ColNum = 4 
     RwNum = RwNum + 4 
     Num = Num + 1 
     'add number 
     Newsh.Cells(RwNum, 1).Value = Num 
     'Copy the sheet name in the column 
     Newsh.Cells(RwNum, 2).Value = Sh.Name 
     'Copy the Description in the column 
     Newsh.Cells(RwNum, 4).Value = Sh.Range("E13") 

     For Each myCell In Sh.Range("A16,B16,F16") '<--Change the range 


      ColNum = ColNum + 2 
      Newsh.Cells(RwNum, ColNum).Value = myCell.Value 
      Newsh.Cells(RwNum + 1, ColNum).Value = myCell.Offset(1, 0).Value 
      Newsh.Cells(RwNum + 2, ColNum).Value = myCell.Offset(2, 0).Value 
      Newsh.Cells(RwNum + 3, ColNum).Value = myCell.Offset(3, 0).Value 
     Next myCell