Results 1 to 8 of 8

Insert Row AFTER every specific txt

Threaded View

needassitance Insert Row AFTER every... 03-23-2011, 05:32 PM
jaslake Re: Insert Row AFTER every... 03-23-2011, 05:52 PM
needassitance Re: Insert Row AFTER every... 03-23-2011, 06:30 PM
needassitance Re: Insert Row AFTER every... 03-23-2011, 06:27 PM
jaslake Re: Insert Row AFTER every... 03-23-2011, 06:38 PM
needassitance Re: Insert Row AFTER every... 03-23-2011, 06:40 PM
Trebor76 Re: Insert Row AFTER every... 03-23-2011, 06:42 PM
jaslake Re: Insert Row AFTER every... 03-23-2011, 07:04 PM
  1. #1
    Registered User
    Join Date
    03-22-2011
    Location
    pakistan
    MS-Off Ver
    Excel 2003
    Posts
    7

    Question Insert Row AFTER every specific txt

    through below mentioned script we can insert row BEFORE specific txt
    but i want same script to insert row AFTER specific txt
    PLEASE RELPY ASAP




    Option Explicit
    
    Sub InsertRows()
    Dim MyVal   As String
    Dim MyCol   As Range
    Dim vFIND   As Range
    Dim vfirst  As Range
    
    MyVal = Application.InputBox("String to insert rows BELOW", Type:=2)
    If MyVal = "False" Then Exit Sub
    
    Set MyCol = Application.InputBox("Highlight a column to search", Type:=8)
    On Error Resume Next
    Set vFIND = MyCol.Find(MyVal, MyCol.Cells(1), xlValues, xlWhole, xlByRows, xlNext, False)
    
        If Not vFIND Is Nothing Then
            Set vfirst = vFIND
            Do
                vFIND.EntireRow.Insert xlShiftUp
                Set vFIND = MyCol.FindNext(vFIND.Offset(1))
            Loop Until vFIND.Address = vfirst.Address
        Else
            MsgBox "Search string not found in the specified column." & vbLf & "No rows added."
        End If
    
    Set MyCol = Nothing
    Set vfirst = Nothing
    Set vFIND = Nothing
    End Sub
    Last edited by needassitance; 03-23-2011 at 07:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1