Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to insert blank row above specific text in Excel?

doc insert row above specific text 1  2 doc insert row above specific text 2

When you work on a worksheet, have you ever tried to insert blank row above a specific text in a column? For example, there are some names in column A, now, I want to insert blank rows above the cells which contain the name “Mike” as the left screenshot shown, maybe, there are no direct way for you to solve this task in Excel. This article, I will talk about some good tricks for dealing with this job in Excel.

Insert blank row above specific text with VBA code

Insert blank row above specific text with Kutools for Excel


Select specific text and insert blank rows above them:

With Kutools for Excel's Select Specific Cells utility, you can quickly select the whole rows which contain the specific text or number as you need, and then you can delete the rows or insert bkank rows above the text as soon as possible.

doc insert row above specific text 8

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Insert blank row above specific text with VBA code


To insert blank row above the specific text manually one by one will waste lots of time, here, I will create a VBA code for you to insert the blank row above specific cell value at once.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and then paste the following macro in the Module Window.

VBA code: Insert blank row above specific text quickly

Sub test1()
'updateby Extendoffice 20151030
    Dim i As Long
    Dim xLast As Long
    Dim xRng As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = Application.ActiveWindow.RangeSelection.Address
    Set xRng = Application.InputBox("please select the column with specific text:", "Kutools for Excel", xTxt, , , , , 8)
    If xRng Is Nothing Then Exit Sub
    If (xRng.Columns.Count > 1) Then
        MsgBox "the selected range must be one column", , "Kutools for Excel"
        Exit Sub
    End If
    xLast = xRng.Rows.Count
    For i = xLast To 1 Step -1
      If InStr(1, xRng.Cells(i, 1).Value, "Mike") > 0 Then
        Rows(xRng.Cells(i, 1).Row).Insert shift:=xlDown
      End If
    Next
End Sub

3. Then press F5 key to run this code, and a dialog box will pop out to remind you select the column data which contains specific text you want to insert row above, see screenshot:

doc insert row above specific text 3

4. And then click OK button, the blank rows have been inserted above the specific text “Mike”.

Note: In the above code, you can change the text value “Mike” to any other values that you desired from the script If InStr(1, xRng.Cells(i, 1).Value, "Mike") > 0 Then.


Insert blank row above specific text with Kutools for Excel

If you have Kutools for Excel, with its Select Specific Cells feature, you can select the specified cell values first, and then apply the Insert Sheet Rows utility of Excel to insert the blank rows at once.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days

After installing Kutools for Excel, please do as follows:

1. Select the data range that you want to use.

2. Then click Kutools > Select > Select Specific Cells, see screenshot:

doc insert row above specific text 4

3. In the Select Specific Cells dialog box, select Cell under the Selection type, and then specify the criteria that you need under the Specific type section, in this case, I will choose Equals from the Specific type, and enter the name that I want to select, see screenshot:

doc insert row above specific text 5

4. Then click Ok button, all the cells which value is Mike are selected at once, see screenshot:

doc insert row above specific text 6

5. After selecting the specific text cells, please click Home > Insert > Insert Sheet Rows, and the blank rows will be inserted above the selected text, see screenshots:

doc insert row above specific text 7  2 doc insert row above specific text 2

 Download and free trial Kutools for Excel Now !


Demo: Insert blank row above specific text with Kutools for Excel

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

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 80% 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!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • 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!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    JK · 11 months ago
    This has been amazing for the data I have. I was wondering if you could help me one step further. I have been able to split my data based on this, but then I need to colour code my groups of data. When I split my data I have a variable number of rows from 1-50, and I have 36 columns of data including 32 columns that I need to compare the values within to the top row. I am currently manually selecting each group (as separated by a blank row) and then using ctrl+shift+| to highlight column differences, and formatting those cells to highlight the differences.


    Is there anyone who could write a code to select and format those column differences within the groupings, using the blank row as a separator?
  • To post as a guest, your comment is unpublished.
    SSJ · 2 years ago
    Hi, i have a similar problem as the one above.
    What if i want to select the cell below a specified criteria?

    For example, you can use the example from above. i want to select the cell below "Mike". is there any easy way out?
    • To post as a guest, your comment is unpublished.
      Shawn · 1 years ago
      @SSJ did you ever find a solution?
      • To post as a guest, your comment is unpublished.
        skyyang · 1 years ago
        Hello, guys,

        To insert blank rows below a specific cell value, you can apply the following code:

        Sub BlankLine()
        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)
        Set WorkRng = WorkRng.Columns(1)
        xLastRow = WorkRng.Rows.Count
        Application.ScreenUpdating = False
        For xRowIndex = xLastRow To 1 Step -1
        Set Rng = WorkRng.Range("A" & xRowIndex)
        If Rng.Value = "Mike" Then
        Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown
        End If
        Next
        Application.ScreenUpdating = True
        End Sub

        Please change the criteria "Mike" to your own cell value.

        Hope it can help you, thank you!