티스토리 뷰
개인적으로 Do Loops가 셀 그룹을 반복하는 것을 좋아하지 않습니다. For Each 루프를 선호합니다.
또한 @bruceWayne이 언급했듯이 Select를 사용하지 않으면 코드가 느려집니다.
적절한 들여 쓰기를 사용하면 코드를 더 쉽게 읽을 수 있고 간단한 실수를 방지 할 수 있습니다.
Dim cel As Range
With Sheets(strSourceSheet)
For Each cel In .Range("AF2", .Range("AF2").End(xlDown))
If Not IsError(cel) Then
strDestinationSheet = cel.Value
cel.Offset(0, -31).Resize(1, cel.CurrentRegion.Columns.Count).Copy
N = Sheets(strDestinationSheet).Cells(Sheets(strDestinationSheet).Rows.Count, "AF").End(xlUp).Row
Sheets(strDestinationSheet).Cells(N + 1, 1).PasteSpecial xlPasteValues
End If
Next cel
End With
출처
https://stackoverflow.com/questions/39920210
댓글