+ Reply to Thread
Results 1 to 3 of 3

how to insert multiple rows in excel 2010 between data

  1. #1
    Registered User
    Join Date
    05-17-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    2

    how to insert multiple rows in excel 2010 between data

    I am trying to insert rows in between part numbers or job numbers on the attached spreadsheet. I am new to this forum and it seems really helpful. I have the following code, but unsuccessful. It would be awesome if someone could improve upon this code.



    Sub InsertRowsV4()

    Dim lLastRow As Long
    Dim i As Long
    Application.ScreenUpdating = False
    lLastRow = Range("A" & Rows.Count).End(xlUp).Row
    For i = lLastRow - 1 To 2 Step -1
    If Range("A" & i + 1).Value - Range("A" & i).Value > 0 Then
    On Error Resume Next
    Range("A" & i + 1).Resize(Range("A" & i + 1).Value - Range("A" & i).Value - 1, 1).EntireRow.Insert
    On Error GoTo 0
    End If
    Next 'i
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: how to insert multiple rows in excel 2010 between data

    Hi Drum,

    Welcome to the forum!!

    Try this where a row is inserted at a change in Col A (so ensure your data is sorted by that column):

    Please Login or Register  to view this content.
    HTH

    Robert

    PS You need to wrap your code with tags as I have done
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    05-17-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: how to insert multiple rows in excel 2010 between data

    Trebor76 you are awesome!!! It works perfectly. Thank you, I will definitely promote this forum in anyway I can.

+ Reply to Thread

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