2012-07-26 2 views
0

여러 Excel 시트의 데이터를 마스터 시트의 한 열로 업데이트하는 방법에 문제가 있습니다. 새 행을 입력 할 때마다 마스터 시트에서 자동으로 업데이트되기를 원합니다. 값은 id이므로 여러 워크 시트에서 고유합니다.여러 Excel 시트의 데이터 업데이트

엑셀 시트 1 :

ID 
--- 
1 
2 
3 
4 
5 

엑셀 시트 2 :

ID 
--- 
12 
23 
34 
41 
53 

엑셀 시트 3 :

ID 
--- 
123 
215 
324 
445 
562 

마스터 엑셀 시트 :

ID 
--- 
1 
2 
3 
4 
5 
12 
23 
34 
41 
53 
123 
215 
324 
445 
562 
예 0

6 (워크 시트 1)과 같이 새 값을 입력 할 때마다 마스터 시트로 업데이트됩니다.

그럴 수 있습니까? 매크로를 사용해야합니까? 감사.

업데이트 SheetChange와 코드()


With DataEntrySheet 

    '** Set variables for using the Find method in a loop 
    Set loopRng = DataEntrySheet.Columns(1) 
    Set lookRng = MasterSheet.Columns(2) 

    '** Set the range which will be used to write data if found 
    Set OldLastCell = DoNotEditSheet.Range(_ 
    "C65536").End(xlUp).Offset(1) 

    '** Start the Find loop 
    For Each iCel In loopRng 

     '** Using the Find method to find the cell value. 
     Set foundRng = lookRng.Find(iCel.Value, lookRng.Cells(1), _ 
     xlValues, xlWhole, MatchCase:=True) 

     '** Test if the variable 'foundRng' is Nothing. If the value 
     ' was not found, the variable will be Nothing, or else it 
     ' will be the Range Object of that (first) found value. 
     If foundRng Is Nothing Then 

      '** Use the two ranges to transfer data (faster than Copy/Paste). 
      OldLastCell.Value = iCel.Value 
      OldLastCell.Offset(, -1).Value = iCel.Offset(, -1).Value 
      OldLastCell.Offset(, 2).Value = iCel.Offset(, 1).Value 
      OldLastCell.Offset(, 5).Value = iCel.Offset(, 2).Value 
      OldLastCell.Offset(, 10).Value = iCel.Offset(, 3).Value 

      '** Reset the variable to be one row below where we wrote the 
      ' data to. This will keep the data organized by rows. 
      Set OldLastCell = OldLastCell.Offset(1) 

     End If 

     '** This MUST be set to Nothing before the next iteration. If not, 
     ' and a match is not found (following a good find) then you may 
     ' have mismatched iterations with false results. 
     Set foundRng = Nothing 
    Next iCel 
End With 

최종 하위

+0

숫자 순서대로 입력해야합니까? 따라서 워크 시트 1에 6이 추가되면 5와 12 사이의 마스터 엑셀 시트에 추가됩니다. 워크 시트 2에 6이 추가되면 아무 일도 일어나지 않을까요? – LittleBobbyTables

+2

예, 가능하고 어렵지 않습니다. 너 뭐 해봤 니? – ApplePie

+0

필요는 없습니다. 필자는 마스터 워크 시트에서 VLOOKUP 함수를 사용하여 차이 워크 시트에서 행운을 빌어 참조하려고했습니다. – user1555907

답변

0

당신은 마스터 워크 시트를 업데이트 할 SheetChange() 이벤트를 사용할 수 있지만,이 믿을 수 없을만큼 데이터 입력 속도를 느리게 할 수있다.

누군가가 데이터를 입력하고 다른 셀로 이동할 때마다 SheetChange 이벤트가 코드를 실행합니다. 데이터 세트의 모든 열이 완료되면 새 데이터 만 확인하는 것이 이상적입니다.

새 행 항목이 완성되어 마스터 시트에 입력 할 준비가되었을 때 버튼을 누르면됩니다. 웹에는 새로운 시트에 불일치 행을 추가하는 수많은 코드 샘플이 있습니다.

+0

이 수준의 세부 사항에서는 답변 척보다 더 많은 코멘트가 있습니다. – brettdj

+0

위의 업데이트 코드를 SheetChange()에 사용하려고했지만 작동하지 않는 것 같습니다. 아이디어가 있습니까? 고맙습니다! – user1555907

관련 문제