2017-02-09 1 views
1

스프레드 시트에 세 개의 워크 시트가 있습니다. 내가 마지막 데이터 행까지 특정 행 복사해서 두 번째, 세 번째 워크 시트에 붙여 넣을하려면 (두 번째, 세 번째 - 첫 번째 워크 시트는 다른 행 번호)다른 시트의 행 복사 - 다른 행 VB 매크로

Dim Source As Worksheet 
    Dim Source As Worksheet 
     Dim Target As Worksheet 
     Dim Target1 As Worksheet 

    Dim LastRow As Long 
    Dim FirstRow2Copy As Long 
     Dim FirstRowCQuote As Long 
     Dim FirstRowIQuote As Long 
    Dim CQFCell As Excel.Range 
     Dim IQFCell As Excel.Range 

     Set Source = ActiveWorkbook.Worksheets("myWorksheet1") 
      Set Target = ActiveWorkbook.Worksheets("mysheet1") 
      Set Target1 = ActiveWorkbook.Worksheets("mysheet2") 


      With Source 'Worksheets("myWorksheet1") Last row 
       LastRow = .Cells(.Rows.Count, "H").End(xlUp).Row '.Cells(.Rows.Count, "A").End(xlUp).Row 
      End With  

     Set FoundCell = ws.Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole) 
     If Not FoundCell Is Nothing Then   
      'Need to copy from this first row to last row 
      FirstRow2Copy = FoundCell.Row + 1 
     End If 
Set CQuoteFCell = Target1.Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole) 
     If Not CQuoteFCell Is Nothing Then 
    FirstRowCQuote = CQuoteFCell.Row + 1 
    End If 

    Set IQuoteFCell = Target1.Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole) 
     If Not IQuoteFCell Is Nothing Then 
    FirstRowIQuote = IQuoteFCell.Row + 1 
    End If 

       'Need to copy rows from FirstRow2Copy untill LastRow - where paste them in Target sheet from RowNumber:FirstRowCQuote, 
        'Paste the same rows in Target1 sheet from RowNumber:FirstRowIQuote 
내가 mysheet1에 대한 행에서 특정 한 경우

답변

0
Dim FoundCell As Range, LastCell As Range 
With Worksheets("myWorksheet1") 
    Set FoundCell = .Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole) 
    If FoundCell Is Nothing Then Exit Sub 
    Set LastCell = .Cells(.Rows.Count, "A").End(xlUp) 
    With .Range(FoundCell.Offset(1), LastCell).EntireRow 
     .Copy Worksheets("mysheet1").Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole).Offset(1) 
     .Copy Worksheets("mysheet2").Range("A:A").Find(what:="Enter the Quantity items:", lookat:=xlWhole).Offset(1) 
    End With 
End With 
+0

을 mysheet2 붙여 넣기는 여기서 할 수 있습니까? 내 질문을 참조하십시오 – Signa

+0

@Signa 수정을했는데 다음에 응답을 게시 한 후 근본적으로 귀하의 질문을 수정하지 마십시오. 이것은 대답을 어떻게 든 이상하게 보입니다. –

+1

ASH .. 감사합니다 ... 불편을 끼쳐 드려 죄송합니다. – Signa

관련 문제