나중에 여러 번 편집 :전체 워크 시트와 시트의 값 비교
여러 시트가있는 Excel 스프레드 시트가 4 ~ 8 개있는 경우 이전 보고서의 정보입니다. 그리고 모든 업데이트 된 값을 포함하는 시트 NIKE가 있습니다. 현재 항목과 새 항목이 NIKE의 행을 읽을 수있는 코드를 작성하고 4 ~ 8 번째 시트에 새로운 행이 있는지 확인합니다.
슬프게도 부분적으로 정상적으로 작동하는 코드가 있는데, 이는 코드가 읽고 필요한 일부 행을 복사 할 수 있음을 의미합니다.
Sub CompareNew()
Dim cellName, cellCl As Range
Dim uF, uFS As Long
Dim sName, ClName As String
Dim sDevice, sImported, sTracker As Worksheet
Application.ScreenUpdating = False
Set sImported = Sheets("NIKE-DOC-REP-DEVICE_SERVICETOCI")
uF = sImported.Range("A" & Rows.Count).End(xlUp).Row
Set sTracker = Sheets("Tracking Add-Delete") 'Hoja de tracking
uFT = sTracker.Range("B" & Rows.Count).End(xlUp).Row
For Each cellName In sImported.Range("A2:A" & uF)
sName = cellName
ClName = cellName.Offset(, 3)
Set sDevice = Worksheets(sName)
uFS = sDevice.Range("B" & Rows.Count).End(xlUp).Row
Set cl = sDevice.Range("E5:E" & uFS).Find(ClName, , , lookat:=xlWhole)
If cl Is Nothing Then
sDevice.Cells(uFS + 1, 2) = sDevice.Cells(uFS, 2) + 1
sImported.Activate
sImported.Range(Cells(cellName.Row, 2), Cells(cellName.Row, 10)).Copy sDevice.Cells(uFS + 1, 3)
sTracker.Cells(uFT + 1, 2) = Format(Date, "[$-en-US]mmmm d, yyyy;@)") 'El codigo ya empieza a copiar informacion a la hoja de Tracking
sImported.Cells(cellName.Row, 4).Copy sTracker.Cells(uFT + 1, 3)
sImported.Cells(cellName.Row, 2).Copy sTracker.Cells(uFT + 1, 4)
sImported.Cells(cellName.Row, 3).Copy sTracker.Cells(uFT + 1, 5)
sTracker.Cells(uFT + 1, 6) = "Added"
Else
End If
Next cellName
Application.ScreenUpdating = True
End Sub
아래의 코드 (현재 행이 통합 문서의 나머지 부분으로 NIKE에서 추가되는 읽기 및 존재하지 않는 경우 나중에 내가 추적기 시트에 복사합니다, 추가합니다이 코드 추가 참조하시기 바랍니다 모든 각각의 시트가 아니라 D 것이다 .. 대향 코드는 아래
Sub CompareOld()
Dim cellName, cellCl As Range
Dim uF, uFS As Long
Dim sName, ClName As String
Dim sDevice, sImported, sTracker As Worksheet
Application.ScreenUpdating = False
wsName = Array("WAN Backbone-DC-RoutersSwitches", "Tools Servers", "Backbone Firewall", "Voice Messaging Managed Device", "NGWAN devices")
For i = 0 To UBound(wsName)
Set sDevice = Worksheets(wsName(i))
uFS = sDevice.Range("B" & Rows.Count).End(xlUp).Row
Set sImported = Sheets("NIKE-DOC-REP-DEVICE_SERVICETOCI")
uF = sImported.Range("A" & Rows.Count).End(xlUp).Row
Set sTracker = Sheets("Tracking Add-Delete")
uFT = sTracker.Range("B" & Rows.Count).End(xlUp).Row
For Each cellName In sDevice.Range("E5:E" & uFS)
ClName = cellName
Set cl = sImported.Range("E5:E" & uFS).Find(ClName, , , lookat:=xlWhole)
If cl Is Nothing Then
sTracker.Activate
sTracker.Cells(uFT + 1, 2) = Format(Date, "[$-en-US]mmmm d, yyyy;@)")
sDevice.Cells(cellName.Row, 5).Copy sTracker.Cells(uFT + 1, 3)
sDevice.Cells(cellName.Row, 3).Copy sTracker.Cells(uFT + 1, 4)
sDevice.Cells(cellName.Row, 4).Copy sTracker.Cells(uFT + 1, 5)
sTracker.Cells(uFT + 1, 6) = "Removed"
sDevice.Rows(cellName.Row).EntireRow.Delete
End If
Next cellName
Next i
Application.ScreenUpdating = True
End Sub
이것을)
를 추적기 시트 모두 copying'em 및 o 기존의 행을 비교하여 현재 행을 비교하고 그 중 하나라도 NIKE 시트에없는 경우 현재 시트에서 제거하고 추적 시트에 복사합니다. (거의 작동하지 않습니다 ... 전혀 모르겠어요!)
첨부 파일은 VBA Module2를 참조하십시오.이 파일에 문제가 있습니다. 어떤 팁을 사전에
파일 아래 https://drive.google.com/file/d/10rXA6fInX5g8zJucrnxsNHl-7vXBpIvz/view?usp=sharing
감사합니다! 그리고 ... 문제에 대해 항상 미안
대신
일부 도움말은 CompareNew 및 CompareOld에 대한 답변을 제공합니다. 이제 트래커 업데이터를 수정해야 할 때입니다. – tanoMandanga