메인 컨텐츠로 가기

Excel에서 값이 변경 될 때 빈 행을 삽입하는 방법은 무엇입니까?

데이터 범위가 있고 이제 값이 변경 될 때 데이터 사이에 빈 행을 삽입하여 다음 스크린 샷과 같이 하나의 열에서 순차적으로 동일한 값을 분리 할 수 ​​있다고 가정합니다. 이 기사에서는이 문제를 해결할 수있는 몇 가지 트릭에 대해 설명합니다.

소계 함수로 값이 변경되면 빈 행 삽입

도우미 열로 값이 변경되면 빈 행 삽입

VBA 코드로 값이 변경되면 빈 행 삽입

강력한 기능으로 값이 변경 될 때 특정 수의 빈 행 삽입


소계 함수로 값이 변경되면 빈 행 삽입

와 더불어 소계 다음 단계에 따라 값이 변경 될 때 데이터 사이에 빈 행을 삽입 할 수 있습니다.

1. 사용할 데이터 범위를 선택하십시오.

2. 딸깍 하는 소리 Data > 소계 를 열려면 소계 대화 상자 및 소계 대화 상자에서 다음 옵션을 수행하십시오.

1: 값이 변경되는 시점을 기준으로 빈 행을 삽입 할 열 이름을 선택합니다. 변경 될 때마다 섹션에서;
2: 선택 카운트 인사말 사용 기능 드롭 다운 목록;
3: 부분합을 삽입 할 열 이름을 다음에 소계 추가 리스트 박스

3. 그런 다음 OK, 다른 제품 사이에 소계 선이 삽입되었으며 테이블 왼쪽에 개요 기호가 표시됩니다. 스크린 샷 참조 :

4. 그런 다음 외곽선 기호 맨 위에있는 숫자 2를 클릭하여 부분합 선만 표시합니다.

5. 그런 다음 소계 범위 데이터를 선택하고 Alt +; 보이는 행만 선택하는 단축키, 스크린 샷 참조 :

6. 보이는 행만 선택한 후 . 키를 누르고 모든 부분합 행이 제거되었습니다.

7. 그런 다음 다른 셀을 클릭하고 돌아가십시오. Data > 그룹 해제 > 명확한 개요 윤곽선을 제거하려면 스크린 샷을 참조하십시오.

8. 개요 기호는 한 번에 지워졌으며 값이 변경되면 데이터 사이에 빈 행이 삽입 된 것을 볼 수 있습니다. 스크린 샷을 참조하십시오.

9. 마지막으로 필요에 따라 열 A를 삭제할 수 있습니다.


값이 빠르게 변경 될 때 페이지 나누기, 빈 행, 아래쪽 테두리 또는 채우기 색상 삽입

당신이 있으면 Excel 용 Kutools's 차이점 구별 기능을 사용하면 필요에 따라 값이 변경 될 때 페이지 나누기, 빈 행, 아래쪽 테두리 또는 채우기 색상을 빠르게 삽입 할 수 있습니다. 아래 데모를 참조하십시오.         Excel 용 Kutools를 다운로드하려면 클릭하십시오!


도우미 열로 값이 변경되면 빈 행 삽입

도우미 열을 사용하면 먼저 수식을 삽입 한 다음 찾기 및 바꾸기 함수는 마지막으로 변경되는 값 사이에 빈 행을 삽입합니다. 다음과 같이하십시오 :

1. 빈 셀 C3에 다음 수식을 입력하십시오. = A3 = A2, D4 셀에 다음 수식을 입력하십시오. = A4 = A3, 스크린 샷 참조 :

2. 그런 다음 C3 : D4를 선택하고 이러한 수식을 적용하려는 범위로 채우기 핸들을 드래그하면 참된 or 거짓 셀에서 스크린 샷을 참조하십시오.

3. 그런 다음 Ctrl + F 키를 눌러 찾기 및 바꾸기 대화 상자에서 튀어 나온 대화 상자에서 그릇된무엇을 찾기 아래 텍스트 상자 Find 탭을 클릭하고 옵션 버튼을 눌러이 대화 상자를 확장하고 마케팅은: 인사말 잠깐 들여다보다 드롭 다운 목록, 스크린 샷 참조 :

4. 모두 찾기 버튼을 누른 다음 Ctrl + 모든 검색 결과를 선택하려면 모든 FALSE 셀이 한 번에 선택되었습니다. 스크린 샷을 참조하십시오.

6. 닫기 찾기 및 바꾸기 대화 상자, 다음 단계에서 클릭하여 빈 행을 삽입 할 수 있습니다. > 끼워 넣다 > 시트 행 삽입, A 열을 기준으로 값이 변경 될 때 빈 행이 데이터에 삽입되었습니다. 스크린 샷을 참조하십시오.

7. 마지막으로 필요에 따라 도우미 열 C와 D를 삭제할 수 있습니다.


VBA 코드로 값이 변경되면 빈 행 삽입

위의 방법을 사용하는 데 지쳤다면 변경된 값 사이에 빈 행을 한 번에 삽입하는 데 도움이되는 코드도 있습니다.

1. 누르고 ALT + F11 키를 눌러 Microsoft Visual Basic for Applications 창.

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

VBA 코드 : 값이 변경되면 빈 행 삽입

Sub InsertRowsAtValueChange()
'Update by Extendoffice
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = WorkRng.Rows.Count To 2 Step -1
    If WorkRng.Cells(i, 1).Value <> WorkRng.Cells(i - 1, 1).Value Then
        WorkRng.Cells(i, 1).EntireRow.Insert
    End If
Next
Application.ScreenUpdating = True
End Sub

3. 그런 다음 F5 키를 눌러이 코드를 실행하면 값이 변경 될 때 빈 행을 삽입 할 하나의 열 데이터를 선택할 수있는 프롬프트 상자가 나타납니다 (스크린 샷 참조).

4. 그런 다음 OK, A 열을 기준으로 값이 변경되면 데이터 사이에 빈 행이 삽입되었습니다.


강력한 기능으로 값이 변경 될 때 특정 수의 빈 행 삽입

위의 번거로운 방법으로 시도해 보시면 여기에서 유용한 도구를 소개하겠습니다. Excel 용 Kutools's 차이점 구별 셀 값이 빠르고 쉽게 변경 될 때 페이지 나누기, 빈 행, 아래쪽 테두리 또는 채우기 색상을 삽입 할 수 있습니다.

팁 :이것을 적용하려면 차이점 구별 먼저 기능을 다운로드해야합니다. Excel 용 Kutools을 클릭 한 다음 기능을 빠르고 쉽게 적용하십시오.

설치 후 Excel 용 Kutools, 다음과 같이하십시오.

1. 딸깍 하는 소리 쿠툴 > 형성 > 차이점 구별, 스크린 샷 참조 :

2. 에서 키 열로 차이점 구분 대화 상자에서 다음 작업을 수행하십시오.

  • 사용할 데이터 범위를 선택한 다음 빈 행을 삽입 할 키 열을 선택합니다.
  • 그런 다음 확인 빈 행 옵션에서 옵션 섹션을 클릭하고 삽입 할 빈 행 수를 입력합니다.

3. 그런 다음 Ok 버튼을 클릭하고 셀 값이 변경되면 특정 수의 빈 행이 데이터에 삽입되었습니다. 스크린 샷을 참조하십시오.

Excel 용 Kutools 및 무료 평가판을 지금 다운로드하려면 클릭하십시오!

최고의 사무 생산성 도구

🤖 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 (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, Hassan,

This vba is amazing, whereas I need one more alternate code for insert single blank row after changes in sequencing numbers. Example:- In column having number series like 1, 2, 3, 5, 6, 9 & etc...
Need to add single blank row between 3 & 5 as well as 6 & 9.
Please can you with this.
This comment was minimized by the moderator on the site
Can the VBA method be adapted to ignore blank cells? I have a file which I need to insert rows in based on two different columns but when I run the macro on the second column I end up with three blank lines where the first macro run inserted rows.
Or can it run on two columns at the same time?
This comment was minimized by the moderator on the site
Hello,
Is very usefull in case i need to insert 1 row, but if i need to insert 145 rows in every time the data change in spwcific column, how can i do it??
This comment was minimized by the moderator on the site
Hi, Hassan,
To insert multiple blank rows when value changes in a specific column, you should apply the following VBA code:

Note: In the below code, you should change the number 99 to your need, for example, when you insert 145 blank rows, you should change the number 99 to 144. Please try it, hope it can help you!

Sub InsertRowsAtValueChange()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = WorkRng.Rows.Count To 2 Step -1
If WorkRng.Cells(i, 1).Value <> WorkRng.Cells(i - 1, 1).Value Then
Range(WorkRng.Cells(i, 1).EntireRow, WorkRng.Cells(i + 99, 1).EntireRow).Insert
End If
Next
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Very helpful. The code that skyyang shows above worked perfectly. Just make sure that the data doesn't already have spaces in it.

I don't understand VBA, but I believe if you wanted to add more rows underneath data that already had the spacing, there should be a way to ignore spaces.

Could a line be added to ignore or skip over blank lines? That might make this code more universal and repeatable if needed. Also a delete function that is similar to this may be useful so undo isn't necessary.
This comment was minimized by the moderator on the site
RE: insert blank rows when value changes with vba code
Is there a way that I can save the Range & not have to pick it every time I run it?
This comment was minimized by the moderator on the site
The VBA code worked 1st time and did exactly what I was trying to do. Thank you so much!
This comment was minimized by the moderator on the site
I've been using my own solution for some time.
1. Insert a helper column into Column A
2. In A2, type "if(B2=B1,A1,A1+1)"
3. Copy that formula down to the last row
4. Copy all the populated cells in column A and Paste Special (Values) over them
5. Copy all the cells again and paste them into column A in the first unpopulated cell (e.g. if you have 104 rows of data plus a header row you would paste into cell A106)
6. Click on Data and Remove Duplicates (only on the cells you just pasted in Step 5; not on all rows)
7. Sort all of Column A
8. Delete Column A

Seems like a lot of steps but only takes a few seconds.
This comment was minimized by the moderator on the site
[quote]Hi all thank you!! its awesome , can you guys also let me how to insert 2 rows when the value changes in VBA or through excel.By Hudson[/quote] Please let me know how to insert more than 1 row.
This comment was minimized by the moderator on the site
Hi there, These are almost useful! The first method doesn't work for me because when I follow the steps explicitly, the the data that I delete in the subtotal panes deletes the entire columns that I've sorted. In the second method when I get to the step where I insert sheet rows, the rows are inserted ABOVE the FALSE cells which breaks up the data, but the last selection of every group is then added to the group below. Any advice???
This comment was minimized by the moderator on the site
Hi all thank you!! its awesome , can you guys also let me how to insert 2 rows when the value changes in VBA or through excel.
This comment was minimized by the moderator on the site
Where in the code would I need to modify to include more than one row, I need to add 10 after each break... Thanks
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations