Why it dosnt work for me???
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.
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.
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!
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:
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.
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:
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:
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 2 months agoI try do it to put a blank row after every non-empty cell, but excel says. "That command cannot be used on multiple selections"
Why it dosnt work for me???
- To post as a guest, your comment is unpublished.· 6 months agoIs 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.· 1 years agoThis 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.· 3 years agoHi, 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.· 2 years ago@SSJ did you ever find a solution?
- To post as a guest, your comment is unpublished.· 2 years agoHello, guys，
To insert blank rows below a specific cell value, you can apply the following code:
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
Application.ScreenUpdating = True
Please change the criteria "Mike" to your own cell value.
Hope it can help you, thank you!
- To post as a guest, your comment is unpublished.· 1 years agothank you! its worked.