read complete row insert as new row

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
i've been playing with this all morning but no progress. Any suggestions would be helpful.


I'm reading in a xls file looking at column I. When I find multiple entries in col "I" separated by a comma, i need to create a new row for each Item I find and insert it into a new row. Right now I have the values in a array but for the life of me, im having trouble from there.

Thanks


the data file would be as such

a b c d e f g h i
1 2 3 4 5 6 7 8 Red
1 2 3 4 5 6 7 8 Blue,
Green,
Yellow
1 2 3 4 5 6 7 8 Brown


The output
a b c d e f g h i
1 2 3 4 5 6 7 8 Red
1 2 3 4 5 6 7 8 Blue
1 2 3 4 5 6 7 8 Green
1 2 3 4 5 6 7 8 Yellow
1 2 3 4 5 6 7 8 Brown



'split ip columns
Dim FullIP As Variant
Dim txt As String


N = Cells(Rows.Count, "A").End(xlUp).Row
For i = 8 To N
txt = Range("I" & i).Value
FullIP = Split(txt, ",")
For j = 0 To UBound(FullIP)


Next j
Next i
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
How about
Code:
Sub Danny54()
    Dim FullIP As Variant
    Dim i As Long

    For i = Range("A" & Rows.Count).End(xlUp).Row To 8 Step -1
        FullIP = Split(Range("I" & i).Value, ",")
        If UBound(FullIP) > 0 Then
            Rows(i + 1).Resize(UBound(FullIP)).Insert
            Rows(i).Resize(UBound(FullIP) + 1).FillDown
            Range("I" & i).Resize(UBound(FullIP) + 1).Value = Application.Transpose(FullIP)
        End If
    Next i
End Sub
 
Upvote 0
Wow,

that worked Great! I'll spend some time with it to fully understand.

Thanks so much!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top