one cell to different rows

itsgagandeep

New Member
Joined
Aug 14, 2011
Messages
8
HI,

Plz help me in this

i got data in one cell
1,2,3,4,5

i want to change this data in different rows like ,
1
2
3
4
5


it should be inserted in the new row, not overwrite the current data .:eeek:
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try like this

Code:
Sub Splt()
Dim X
With Range("A1")
    X = Split(.Value, ",")
    .Offset(1).Resize(UBound(X) + 1).Value = Application.Transpose(X)
End With
End Sub
 
Upvote 0
Try

Code:
Sub Splt()
Dim X
With Range("A1")
    X = Split(.Value, ",")
    .Offset(1).Resize(UBound(X) + 1).Insert shift:=xlShiftDown
    .Offset(1).Resize(UBound(X) + 1).Value = Application.Transpose(X)
End With
End Sub
 
Upvote 0
its like below,

i got below data,

A1 B1
1]gaga 1,2,3,4
2]vog a,b,c


i want the data in below format

A1 B1
1] gaga 1
2] 2
3] 3
4] 4
5]vog a
6] b
7] c
 
Upvote 0
Try

Code:
Sub Splt()
Dim X
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    With Range("B" & i)
        X = Split(.Value, ",")
        .Offset(1).Resize(UBound(X)).EntireRow.Insert
        .Resize(UBound(X) + 1).Value = Application.Transpose(X)
    End With
Next i
End Sub
 
Upvote 0
But, can i skip this all if there is no value or just one value in the cell for a particular row? i.e. there is no comma.
 
Upvote 0
Try

Code:
Sub Splt()
Dim X
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    With Range("B" & i)
        If .Value <> "" Then
            X = Split(.Value, ",")
            If UBound(X) > 0 Then
                .Offset(1).Resize(UBound(X)).EntireRow.Insert
                .Resize(UBound(X) + 1).Value = Application.Transpose(X)
            End If
        End If
    End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

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