주요 6 열 수 있습니다.
- 는
- 가 시트 (2)의 온도 값을 비교하여 각 행의 루프를 시작 행마다 임시 값을 설정
- 시트 (1)를 통해 반복하여 시작한다. 일치
- 복사 행 없었다 경우
- 계속 열을 통해 반복하여, 시트 2의 루프의 끝에서 일치 여부를
- 이 있다면
- 추적하는 부울 변수를 사용하여 시트 통해 반복하는 1
코드 :
이 할 수있는 아주 쉬운 일입니다
Sub CopyNoMatch()
Dim lastSourceRow As Long
Dim source As String, target As String
Dim tempVal As String
Dim tRow As Long, lRow As Long, lCol As Long, nRow As Long
Dim match As Boolean
source = "Sheet1"
target = "Sheet2"
lastSourceRow = Sheets(source).Range("A" & Rows.count).End(xlUp).row
For lRow = 2 To lastSourceRow 'Loop through Rows on Sheet1
match = False 'Reset boolean test for each new row
tempVal = Sheets(source).Cells(lRow, "B").Text 'Assign the tempValue to compare
For tRow = 2 To lastTargetRow 'Loop through entire target sheet
If Sheets(target).Cells(tRow, "B").Text = tempVal Then
match = True
End If
Next tRow
If match = False Then 'No Match found, copy row
nRow = Sheets(target).Range("A" & Rows.count).End(xlUp).row + 1
For lCol = 1 To 6 'Copy entire row by looping through 6 columns
Sheets(target).Cells(nRow, lCol).Value = Sheets(source).Cells(lRow, lCol).Value
Next lCol
Next lRow
End Sub
, 당신은 그것을 시도를 제공하거나 처음에 질문을 구글해야하고 있었다 여기에 질문을 게시하는 데 문제가 있습니다. 이것은 '게으른'질문이라고 할 수 있습니다. – ehsan88
내가 한 코드는 그저 당황 스러울 뿐이었다. – dcoder123
당혹스럽지 마라. 실수로 질문을 올리면 미래의 누군가가 그 질문을 배우게됩니다. 어느 쪽이든, 코드를 게시하면 도움을받을 가능성이 더 큽니다. – peege