How to insert blank rows when value changes in Excel?
Insert blank rows & columns: (Insert every other or nth rows / columns)
Kutools for Excel’s Insert Blank Rows & Columns can help you insert every other rows or columns into existing data.
Insert blank rows when value changes with Subtotal function
With the Subtotal feature, you can insert blank rows between the data when value changes as following steps:
1. Select the data range that you want to use.
2. Click Data > Subtotal to open the Subtotal dialog box, and in the Subtotal dialog, please do the following options:
A: Select the column name which you want to insert blank rows based on when the value changes under At each change in section;
B: Choose Count from the Use function drop down list;
C: Check the column name that you want to insert the subtotal to in the Add subtotal to list box
3. Then click OK, the subtotal lines have been inserted between the different products, and the outline symbols are displayed at the left of the table, see screenshot:
4. And then click the number 2 at the top of the outline symbol to just only display the subtotal lines.
5. Then select the subtotal range data, and press Alt+; shortcut keys to select the visible rows only, see screenshot:
6. After selecting the visible rows only then press the Delete key on the keyboard, and all the subtotal rows have been removed.
7. Then click any other cell, and go back Data > Ungroup > Clear Outline to remove the Outlines, see screenshot:
8. The outline symbols have been cleared at once, and you can see blank rows have been insert between the data when value changes, see screenshot:
9. At last, you can delete the column A as you need.
Insert blank rows when value changes with helper columns
With the helper columns, you can insert formula first, and then apply the Find and Replace function, at last, insert the blank rows between the changing values. Please do as follows:
1. In a blank cell C3, please enter this formula =A3=A2, and in cell D4 enter this formula =A4=A3, see screenshot:
2. Then select C3:D4, and drag the fill handle over to the range that you want to apply theses formulas, and you will get True or False in the cells, see screenshot:
3. And then press Ctrl + F keys to open the Find and Replace dialog, in the popped out dialog, enter FALSE into the Find what text box under Find tab, and click Options button to expand this dialog, and choose Values from the Look in drop down list, see screenshot:
4. Click Find All button, and then press Ctrl + A to select all the results of finding, see screenshot:
5. And all the FALSE cells have been selected at once, then close the Find and Replace dialog box.
6. Next step, you can insert blank rows by clicking Home > Insert > Insert Sheet Rows, and blank rows have been inserted into the data when value changes based on column A, see screenshots:
7. Finally, you can delete the helper column C and D as you need.
Insert blank rows when value changes with VBA code
If you are tired of using the above methods, here is a code also can help you to insert blank rows between the changed values at once.
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Insert blank rows when value changes
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
Application.ScreenUpdating = True
3. Then press F5 key to run this code, and a prompt box will pop out to let you select one column data that you want to insert blank rows when value changes which you based on, see screenshot:
4. And then click OK, the blank rows have been inserted between data when the value changes based on column A.
Recommended Productivity Tools
Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings
300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for
1500+ work scenarios, helps you solve
82% Excel problems.
- Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
- Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
- Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
- No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
- Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
- 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
- Change the way you work now, and give you a better life immediately!
- Increases your productivity by
50% when viewing and editing multiple documents.
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Open and create documents in new tabs of same window, rather than in new windows.
- Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!