A 열의 값이 sheet2의 같은 열의 값과 일치하면 sheet1을 확인할 매크로가 있습니다. 그렇다면 각 셀에 대해 인접 셀을 복사합니다 sheet1에서 sheet2로 일치하는 값. 아래는 내가 지금까지 가지고 있지만 lastrowadd 라인에 'run error 9'가 계속 나오고 이유를 모르겠습니다. 어떤 도움을 주시면 감사하겠습니다 :) 작은 변화의 몇 lastrowAdd
및 lastrowRemove
모두가 정의 된 방식으로 포함되었습니다Excel VBA는 일치하는 기준에 따라 다른 시트의 인접한 열을 복사합니다.
Sub CopyAdjacent()
Dim i As Long, j As Long, colStatus As Long, lastrowAdd As Long, lastrowRemove As Long
colStatus = 2 'your status column number
lastrowAdd = Sheets(“Sheet1”).Cells(Sheets(“Sheet1”).Rows.Count, 1).End(xlUp).Row
lastrowRemove = Sheets(“Sheet2”).Cells(Sheets(“Sheet2”).Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrowAdd
For j = 1 To lastrowRemove
If Sheets(“Sheet1”).Cells(i, 1).Value = Sheets(“Sheet2”).Cells(j, 1).Value Then
Sheets(“Sheet2”).Cells(j, colStatus).Value = Sheets(“Sheet1”).Cells(i, colStatus).Value
End If
Next j
Next i
End Sub
'장 ("시트 1"). 세포 (장 ("시트 1"). Rows.Count 1) .END (xlUp)은 스프레드 시트 ("시트 1') '이 변경 시도 .Row'. 행 .Count-1' 그리고 무슨 일이 일어나는 지 알아보기 – Saechel
여전히 같은 결과를 준다. – Steven