Hi Eveyone and Expert.
I need help.. I want to insert row base on the cell value. Can anyone help me out here?
I need help.. I want to insert row base on the cell value. Can anyone help me out here?
VBA Code:
Sub BlankLine()
'Updateby20150203
Dim Rng As Range
Dim WorkRng As Range
Dim xInsertNum As Long
' On Error Resume Next
xTitleId = "Kutools for Excel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
If WorkRng Is Nothing Then Exit Sub
xInsertNum = Application.InputBox("The number of blank rows you want to insert", xTitleId, Type:=1)
If xInsertNum = False Then
MsgBox " The number of blank rows you want to insert ", vbInformation, xTitleId
Exit Sub
End If
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 InStr(Rng.Value, "ALLEN") = 0 And InStr(Rng.Value, "ATC") = 0 And IsNumeric(Rng.Value) And Rng.Value > 0 Then
Rng.Offset(1, 0).Resize(xInsertNum).EntireRow.Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: