+ Reply to Thread
Results 1 to 5 of 5

Insert new rows as per the delimits

Hybrid View

  1. #1
    Registered User
    Join Date
    01-03-2016
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    17

    Insert new rows as per the delimits

    If column "A" contains data with delimiters " | " then it should check column "B" and if column "B" is blank. Macro should run by inserting new rows to the count of delimiters " | " present in column " A" and should copy data from column G to column K.

    Before and After screen shot, excel attached.

    Please help!!
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Insert new rows as per the delimits

    Heres one way

    Sub abc()
     For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        sDelimiter = Cells(r, 1)
        If InStr(1, sDelimiter, "|", vbTextCompare) Then
            a = Split(sDelimiter, "|")
             For ii = 1 To UBound(a)
                Cells(r, 1).Offset(1).EntireRow.Insert shift:=xlDown
             Next
             Cells(r, 1).Resize(UBound(a) + 1) = Application.Transpose(a)
        End If
     Next
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    01-03-2016
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    17

    Re: Insert new rows as per the delimits

    @ Mike Half satisfied with your prompt response but every new line inserted need to copy the data's present from column G to column K.
    You can see in the output file an example.
    Looking forward your response.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Insert new rows as per the delimits

    Give this a try

    Sub abc()
     Application.ScreenUpdating = False
     For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        sDelimiter = Cells(r, 1)
        If InStr(1, sDelimiter, "|", vbTextCompare) Then
            a = Split(sDelimiter, "|")
             arr = Cells(r, "G").Resize(, 5)
             For ii = 1 To UBound(a)
    
                With Range("A" & r).Offset(1)
                    .EntireRow.Insert shift:=xlDown, copyorigin:=xlAbove
                    .Offset(-1, 6).Resize(, 5) = arr
                End With
    
             Next
             Cells(r, 1).Resize(UBound(a) + 1) = Application.Transpose(a)
        End If
     Next
     Columns("K:K").WrapText = True
     Application.ScreenUpdating = True
    End Sub
    Last edited by mike7952; 01-03-2016 at 10:59 PM.

  5. #5
    Registered User
    Join Date
    01-03-2016
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    17

    Re: Insert new rows as per the delimits

    Thanks Mike
    It is perfect now but need to check with large data's.
    Marked the report as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Insert Rows on Criteria and Copy content to Specific Cells in New Rows(Tables)
    By TheScott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2015, 03:38 PM
  2. [SOLVED] VBA codes to insert the rows and copy the first entire row text and insert sheet
    By PRADEEPB270 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2013, 05:05 AM
  3. Insert header , hide rows and insert page breaks
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2013, 10:10 AM
  4. Insert header , hide rows and insert page breaks
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2013, 03:28 AM
  5. Insert new row & prompt to ask how many rows to insert
    By lady_kay in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-03-2013, 04:34 AM
  6. [SOLVED] VBA insert/delete rows to accommodate exact number of rows from incoming data
    By iloc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2012, 06:19 PM
  7. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 PM

Tags for this Thread

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