메인 컨텐츠로 가기

중복 행을 Excel의 다른 시트로 이동하는 방법은 무엇입니까?

특정 열에 일부 중복 값이 ​​포함 된 데이터 범위 목록이있는 경우 이제 중복 셀을 기반으로 전체 행을 다른 시트로 이동하려고합니다. Excel에서이 작업을 어떻게 처리 할 수 ​​있습니까?

열의 중복 셀을 기반으로 전체 행을 다른 시트로 이동

중복 행을 기반으로 전체 행을 다른 시트로 이동


열의 중복 셀을 기반으로 전체 행을 다른 시트로 이동

열에 중복 값이있는 경우 전체 행을 다른 시트로 이동하면 다음 VBA 코드가 도움이 될 수 있습니다.

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 모듈 창에 다음 코드를 붙여 넣습니다.

VBA 코드 : 열의 중복 셀을 기반으로 전체 행을 다른 시트로 이동합니다.

Sub CutDuplicates()
'Updateby Extendoffice
    Dim xRgS As Range
    Dim xRgD As Range
    Dim I As Long, J As Long
    On Error Resume Next
    Set xRgS = Application.InputBox("Please select the column:", "KuTools For Excel", Selection.Address, , , , , 8)
    If xRgS Is Nothing Then Exit Sub
    Set xRgD = Application.InputBox("Please select a desitination cell:", "KuTools For Excel", , , , , , 8)
    If xRgD Is Nothing Then Exit Sub
    xRows = xRgS.Rows.Count
    J = 0
    For I = xRows To 1 Step -1
        If Application.WorksheetFunction.CountIf(xRgS, xRgS(I)) > 1 Then
            xRgS(I).EntireRow.Copy xRgD.Offset(J, 0)
            xRgS(I).EntireRow.Delete
            J = J + 1
        End If
    Next
End Sub

3. 그런 다음 F5 키를 눌러이 코드를 실행하고 튀어 나온 대화 상자에서 이동하려는 중복 셀이 포함 된 열을 선택하고 스크린 샷을 참조하십시오.

4. 그런 다음 OK, 다른 프롬프트 상자에서 이동 된 행을 넣을 다른 시트의 셀을 선택하십시오. 스크린 샷을 참조하십시오.

5. 그런 다음 OK, A 열에 중복 값이있는 행이 새 시트로 이동되었습니다. 스크린 샷 참조 :


중복 행을 기반으로 전체 행을 다른 시트로 이동

셀 범위에서 중복 행을 이동하려는 경우 다음 VBA 코드가 도움이 될 수 있습니다.

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 모듈 창에 다음 코드를 붙여 넣습니다.

VBA 코드 : 중복 행을 기반으로 전체 행을 다른 시트로 이동합니다.

Sub CutDuplicates()
'Updateby Extendoffice
    Dim xRgD As Range, xRgS As Range
    Dim I As Long, J As Long, K As Long, KK As Long
    On Error Resume Next
    Set xRgS = Application.InputBox("Please select the data range:", "KuTools For Excel", Selection.Address, , , , , 8)
    If xRgS Is Nothing Then Exit Sub
    Set xRgD = Application.InputBox("Please select a desitination cell:", "KuTools For Excel", , , , , , 8)
    If xRgD Is Nothing Then Exit Sub
    KK = 0
    For I = xRgS.Rows.Count To 1 Step -1
        For J = 1 To I - 1
            For K = 1 To xRgS.Columns.Count
                Debug.Print xRgS.Rows(I).Cells(, K).Value
                Debug.Print xRgS.Rows(J).Cells(, K).Value
                If xRgS.Rows(I).Cells(, K).Value <> xRgS.Rows(J).Cells(, K).Value Then Exit For
            Next
            If K = xRgS.Columns.Count + 1 Then
                xRgS.Rows(I).EntireRow.Copy xRgD.Offset(KK, 0).EntireRow
                xRgS.Rows(I).EntireRow.Delete
                KK = KK + 1
            End If
        Next
    Next
End Sub

3. 그런 다음 F5 이 코드를 실행하려면 키를 누르고 팝업 대화 상자에서 중복 행을 이동하려는 데이터 범위를 선택하십시오. 스크린 샷을 참조하십시오.

4. 딸깍 하는 소리 OK 버튼을 누른 다음 다른 프롬프트 상자에서 이동 된 요청 행을 넣을 새 시트의 셀을 선택합니다 (스크린 샷 참조).

5. 그런 다음 OK 버튼을 클릭하면 중복 행이 한 번에 지정한 다른 시트로 이동되었습니다. 스크린 샷을 참조하십시오.

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hola buenas,

Tenia una pregunta con respecto a esta macro; Esta macro es exactamente lo que necesito y funciona perfectamente, pero mi problema es que solo funciona en grupo de datos que no sean muy grandes.

Cuando la aplico sobre un grupo de datos grandes (en mi caso, 50mil filas), excel inevitablemente colapsa; He probado muchas cosas pero sigue colapsando.

Hay alguna manera de hacer que la macro funcione en estos casos? alguna idea? Gracias de antemano.

Rafael.
This comment was minimized by the moderator on the site
Hello, Rafael

Yes, as you said, if the data is large, the vba code will not work perfectly. In this case, you can use the auxiliary column to mark the duplicate row first, then use the filter function to filter out the duplicate row, finally copy the duplicate row to another worksheet. Please see the below demo:
To find the duplicate rows, please apply this formula: =IF(COUNTIFS($A$2:$A2,$A2,$B$2:$B2,$B2,$C$2:$C2,$C2) >1, "Duplicate row", "")
If you just want to find the duplicate cells in one column, please apply this formula: =IF(COUNTIFS($A$2:$A2,$A2) >1, "Duplicate row", "")
https://www.extendoffice.com/images/stories/comments/comment-skyyang/move-duplicates.gif
Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hola, que tal,

Tengo una duda con respecto a esta macro; La macro funciona perfectamente y es justo lo que necesito, el problema es que habitualmente necesito utilizarla con tablas de excel en las que hay como mas de 50 mil entradas.

Al utilizarla, Excel inevitablemente se colapsa y no responde.

Hay alguna manera de conseguir que esta macro funcione en estos casos? O quizas, conseguir alguna formula/combinacion de formulas en excel que haga lo mismo? Lo comento porque en el caso de las formulas, normalmente excel no suele tardar tanto en procesar y lo resuelve mas rapido.

Un saludo, y gracias.

Rafael.
This comment was minimized by the moderator on the site
For some reason. This worked once, but I cant run it again. IT keeps timing out. Any tips?
This comment was minimized by the moderator on the site
It's working bro!!!!! Thanks.
This comment was minimized by the moderator on the site
This is exactly what I was looking for, thank you! I did it wrong the first few times and then it kept freezing. But once I did it exactly like the screenshots (selecting the exact range, copy/pasting the headers in the other sheet, and only selecting the first field under the first header) the macros was instantaneous.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations