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".

ABCDEF G
WireslessTowers14100900TE000001BzTkfJessicaDan AndersonPurple10/8/2014 Yellow
HAWK14100800TE000001BzTkfJessica=R[-1]C=R[-1]C10/8/2014=R[-1]C
FLTComdata14100700TE000001BzTkfJessica=R[-1]C=R[-1]C10/8/2014=R[-1]C

<tbody>
</tbody>


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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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