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!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

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!
officetab bottom
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.
    Satyam · 2 months ago
    Is there a way not to appears dialog box with pop out to remind me to select the column data which contains specific text I want to insert row above, If a specified cell is filled with data, then process run automatically , without promptings, and insert row above?
  • To post as a guest, your comment is unpublished.
    JK · 1 years 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 · 3 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!