How to insert blank row above specific text in Excel?
![]() |
![]() |
![]() |
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
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
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:
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 30 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:
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:
4. Then click Ok button, all the cells which value is Mike are selected at once, see screenshot:
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:
![]() |
![]() |
![]() |
Download and free trial Kutools for Excel Now !
Demo: Insert blank row above specific text with Kutools for Excel
Best Office Productivity Tools
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!







