티스토리 뷰

개인적으로 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
댓글
공지사항
Total
Today
Yesterday
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30