Skip to main content

How to insert blank rows when value changes in Excel?

Author: Xiaoyang Last Modified: 2024-08-21
sample data arrow right insert blank rows when value changes

Supposing you have a range of data, and now you want to insert blank rows between the data when value changes, so that you can separate the sequential same values in one column as following screenshots shown. In this article, I will talk about some tricks for you to solve this problem.

Insert blank rows when value changes with Subtotal function

Insert specific number of blank rows when value changes with a powerful feature

Insert blank rows when value changes with helper columns

Insert blank rows when value changes with VBA code


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:

 specify the operations in the Subtotal dialog
1: Select the column name which you want to insert blank rows based on when the value changes under At each change in section;
2: Choose Count from the Use function drop down list;
3: 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:

the subtotal lines have been inserted between the different products

4. And then click the number 2 at the top of the outline symbol to just only display the subtotal lines.

click the number 2 to display the subtotal lines

5. Then select the subtotal range data, and press Alt+; shortcut keys to select the visible rows only, see screenshot:

press shortcut keys to select the visible rows

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:

click Clear Outline to remove the Outlines

8. The outline symbols have been cleared at once, and you can see blank rows have been inserted between the data when value changes, see screenshot:

blank rows have been inserted between the data when value changes

9. At last, you can delete the column A as you need.


Insert specific number of blank rows when value changes with a powerful feature

If you are tried with the above troublesome methods, here, I will introduce a useful tool, Kutools for Excel's Distinguish differences can help you to insert page break, blank rows, bottom border or fill color when cell value changes quickly and easily.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

Tips:To apply this Distinguish differences feature, firstly, you should download the Kutools for Excel, and then apply the feature quickly and easily.

After installing Kutools for Excel, please do as this:

1. Click Kutools > Format > Distinguish differences, see screenshot:

click Distinguish differences feature of kutools

2. In the Distinguish differences by key column dialog box, please do the following operations:

  • Select the data range that you want to use, and then choose the key column you want to insert blank rows based on;
  • Then check Blank row option from the Options section, and enter the number of blank rows that you want to insert.

set the operations in the dialog box

3. Then click Ok button, and the specific number of blank rows have been inserted into the data if cell value changes, see screenshots:

original data arrow right the specific number of blank rows have been inserted into the data if cell value changes

Click to Download Kutools for Excel and free trial Now!


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:

create two helper columns with formulas

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:

drag and fill the formulas to other cells

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:

specify the operations in the Find and Replace dialog

4. Click Find All button, and then press Ctrl + A to select all the results of finding, all FALSE cells have been selected at once, see screenshot:

press Ctrl + A to select all the results of finding

6. Close the Find and Replace dialog, 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:

 click Insert Sheet Rows feature arrow right blank rows have been inserted into the data when value changes

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

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. 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:

vba code to select the data range

4. And then click OK, the blank rows have been inserted between data when the value changes based on column A.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!