How to split single text cell into multiple rows, using a comma delimiter?

anasim

New Member
Joined
Oct 9, 2014
Messages
1
Hi Team,

I have been following the thread below to split comma separated text cell in to multiple rows. I am very close to making it work but for some reason it is not copying down adjacent column information.

http://www.mrexcel.com/forum/excel-...into-multiple-rows-using-comma-delimiter.html

For example, I have data that runs from A-G columns. The data that needs to be split into multiple rows is in column A and the code copies down associated information for column B, C and one date column in F but does not take down the information for columns D, E, and G. Instead it gives an entry of "=R[-1]C".

[TABLE="width: 1239"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD] G[/TD]
[/TR]
[TR]
[TD]WireslessTowers141009[/TD]
[TD]00TE000001BzTkf[/TD]
[TD]Jessica[/TD]
[TD]Dan Anderson[/TD]
[TD]Purple[/TD]
[TD]10/8/2014[/TD]
[TD] Yellow[/TD]
[/TR]
[TR]
[TD] HAWK141008[/TD]
[TD]00TE000001BzTkf[/TD]
[TD]Jessica[/TD]
[TD]=R[-1]C[/TD]
[TD]=R[-1]C[/TD]
[TD]10/8/2014[/TD]
[TD]=R[-1]C[/TD]
[/TR]
[TR]
[TD] FLTComdata141007[/TD]
[TD]00TE000001BzTkf[/TD]
[TD]Jessica[/TD]
[TD]=R[-1]C[/TD]
[TD]=R[-1]C[/TD]
[TD]10/8/2014[/TD]
[TD]=R[-1]C[/TD]
[/TR]
</tbody>[/TABLE]


This makes me think that the code is not working in the highlighted red area:
[
Sub Splt()
Dim LR As Long, i As Long
Dim X As Variant
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
Columns("A").Insert
For i = LR To 1 Step -1
With Range("B" & i)
If InStr(.Value, ",") = 0 Then
.Offset(, -1).Value = .Value
Else
X = Split(.Value, ",")
.Offset(1).Resize(UBound(X)).EntireRow.Insert
.Offset(, -1).Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
End If
End With
Next i
Columns("B").Delete
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B:G" & LR)
On Error Resume Next
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
On Error GoTo 0
.Value = .Value
End With
Application.ScreenUpdating = True
End Sub
]

Please let me know how I can tweak the code to work for all columns. I would really appreciate your help.

Thank you!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
That line of code basically says all blank cells should copy the preceding cell in their respective columns. The compiler should be converting those to A1 format and you should be getting a formula like '=E2' in cell E3, '=E3' in cell E4, etc. which would fill in the cells. Are you saying that the compiler is not converting to A1 format? Is your system set to R1C1?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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