Macro to find a value within a cell and insert lines

bgoree09

New member
Joined
Aug 20, 2013
Messages
179
Reaction score
0
Points
0
Good afternoon,

I need a snippet of code that will run down column A and find a value, I'll call it 'x'. At x, I would like to insert lines (preferably an input box would ask the user the number of rows) with x remaining on the bottom after the insertion. X will be a unique value and will be the only contents of the cell. After this I think I can handle the rest :smile:.

Thanks in advance,
 

NoS

New member
Joined
Jan 17, 2013
Messages
832
Reaction score
0
Points
0
Location
British Columbia
Excel Version(s)
Excel 2010
Maybe something like this?
Code:
Sub Insert_Rows()
    Dim x
    Dim y
    Dim InsertSpot
    
    x = "string to find"
    
    On Error Resume Next
    InsertSpot = Application.Match(x, Columns("A:A"), 0)
    On Error GoTo 0
    
    If IsError(InsertSpot) Then
        MsgBox "Didn't find  " &  x
    Else
        y = InputBox("Rows to insert")
        Range("A" & InsertSpot).EntireRow.Resize(y).Insert
    End If
End Sub
 
Top