Split cell content into multiple separate rows in Excel
Suppose in A1 cell I have some comma separated letters.
content(A1 cell) = A, W, L, F
I would like to the following result:
content(A2 cell) = A
content(A3 cell) = W
content(A4 cell) = L
content(A5 cell) = F
However if I type in A1 cell the following:
content(A1 cell) = S, E, U, F, H, R, T
I would like to be the result:
content(A2 cell) = S
content(A3 cell) = E
content(A4 cell) = U
content(A5 cell) = F
content(A6 cell) = H
content(A7 cell) = R
content(A8 cell) = T
Is there a function which will do this job? For example I would like to a function formula in B1 cell, which checks the content of A1 cell and its outputs will be the above results.
Any help appreciated.
microsoft-excel microsoft
add a comment |
Suppose in A1 cell I have some comma separated letters.
content(A1 cell) = A, W, L, F
I would like to the following result:
content(A2 cell) = A
content(A3 cell) = W
content(A4 cell) = L
content(A5 cell) = F
However if I type in A1 cell the following:
content(A1 cell) = S, E, U, F, H, R, T
I would like to be the result:
content(A2 cell) = S
content(A3 cell) = E
content(A4 cell) = U
content(A5 cell) = F
content(A6 cell) = H
content(A7 cell) = R
content(A8 cell) = T
Is there a function which will do this job? For example I would like to a function formula in B1 cell, which checks the content of A1 cell and its outputs will be the above results.
Any help appreciated.
microsoft-excel microsoft
1
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
1
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
1
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56
add a comment |
Suppose in A1 cell I have some comma separated letters.
content(A1 cell) = A, W, L, F
I would like to the following result:
content(A2 cell) = A
content(A3 cell) = W
content(A4 cell) = L
content(A5 cell) = F
However if I type in A1 cell the following:
content(A1 cell) = S, E, U, F, H, R, T
I would like to be the result:
content(A2 cell) = S
content(A3 cell) = E
content(A4 cell) = U
content(A5 cell) = F
content(A6 cell) = H
content(A7 cell) = R
content(A8 cell) = T
Is there a function which will do this job? For example I would like to a function formula in B1 cell, which checks the content of A1 cell and its outputs will be the above results.
Any help appreciated.
microsoft-excel microsoft
Suppose in A1 cell I have some comma separated letters.
content(A1 cell) = A, W, L, F
I would like to the following result:
content(A2 cell) = A
content(A3 cell) = W
content(A4 cell) = L
content(A5 cell) = F
However if I type in A1 cell the following:
content(A1 cell) = S, E, U, F, H, R, T
I would like to be the result:
content(A2 cell) = S
content(A3 cell) = E
content(A4 cell) = U
content(A5 cell) = F
content(A6 cell) = H
content(A7 cell) = R
content(A8 cell) = T
Is there a function which will do this job? For example I would like to a function formula in B1 cell, which checks the content of A1 cell and its outputs will be the above results.
Any help appreciated.
microsoft-excel microsoft
microsoft-excel microsoft
edited Feb 1 at 5:05
angelofdev
869120
869120
asked Jan 17 at 7:29
DomdamoDomdamo
182
182
1
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
1
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
1
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56
add a comment |
1
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
1
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
1
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56
1
1
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
1
1
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
1
1
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56
add a comment |
2 Answers
2
active
oldest
votes
formula
=INDEX(MID(SUBSTITUTE($A$1,", ",""),ROW($A$1:INDIRECT("a"&LEN(SUBSTITUTE($A$1,", ","")))),1),ROWS($A$1:A1))
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
add a comment |
Split Cell Into Rows
Functions do not work in the way you described the possible functionality in your question, but here is a 'similar' VBA solution using the Worksheet Change Event.
Highlights
- In
Worksheet_Change
you can choose (provide) the Split Cell Range
Address containing the delimited data (cStrCell
) and the Split
Delimiter (cStrDel
). - When changing the data in the Split Cell Range, the solution will
copy the delimited data below the Split Cell Range into the
Split Data Range and delete all data below. - The change of any cell in the Split Data Range is not possible.
Copy the following code to the desired sheet code window e.g. Sheet1(Code).
The Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cStrCell As String = "A1" ' Split Cell Range Address
Const cStrDel As String = "," ' Split Delimiter
Application.EnableEvents = False
' Check if changed cell range is contained in Split Range.
If Not Intersect(Target, Range(cStrCell).Resize(UBound(Split( _
Range(cStrCell), cStrDel)) + 2)) Is Nothing Then
On Error GoTo ProcedureExit
' Check if changed cell range address
' is equal to Split Cell Range Address.
If Target.Address = Range(cStrCell).Address Then
' Clear contents of data below Split Range.
Range(Range(cStrCell).Offset(1), Cells(Rows.Count, _
Range(cStrCell).Column).End(xlUp)).ClearContents
End If
' Fill Split Range with Split Data
' i.e. copy Split Data below Split Cell Range.
SplitToRows Range(cStrCell), cStrDel
End If
ProcedureExit:
Application.EnableEvents = True
End Sub
Sub SplitToRows(SplitCellRange As Range, Optional Delimiter As String = ",")
Dim vntS As Variant ' Source Array
Dim vntT As Variant ' Target Array
Dim i As Long ' Arrays Row Counter
' Split first cell in SplitCellRange by Delimiter into Source Array.
vntS = Split(SplitCellRange.Cells(1, 1), Delimiter)
' Resize 2D one-based Target Array.
ReDim vntT(1 To UBound(vntS) + 1, 1 To 1)
' Trim and copy from Source to Target Array.
For i = 0 To UBound(vntS)
vntT(i + 1, 1) = Trim(vntS(i))
Next
' Copy Target Array to Target Range below SplitCellRange.
SplitCellRange.Cells(1, 1).Offset(1).Resize(UBound(vntT)) = vntT
End Sub
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395255%2fsplit-cell-content-into-multiple-separate-rows-in-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
formula
=INDEX(MID(SUBSTITUTE($A$1,", ",""),ROW($A$1:INDIRECT("a"&LEN(SUBSTITUTE($A$1,", ","")))),1),ROWS($A$1:A1))
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
add a comment |
formula
=INDEX(MID(SUBSTITUTE($A$1,", ",""),ROW($A$1:INDIRECT("a"&LEN(SUBSTITUTE($A$1,", ","")))),1),ROWS($A$1:A1))
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
add a comment |
formula
=INDEX(MID(SUBSTITUTE($A$1,", ",""),ROW($A$1:INDIRECT("a"&LEN(SUBSTITUTE($A$1,", ","")))),1),ROWS($A$1:A1))
formula
=INDEX(MID(SUBSTITUTE($A$1,", ",""),ROW($A$1:INDIRECT("a"&LEN(SUBSTITUTE($A$1,", ","")))),1),ROWS($A$1:A1))
answered Jan 17 at 9:30
vivekvivek
662
662
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
add a comment |
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
1
1
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
to remove error (#REF!) , add iferror function . something like : IFERROR(aboveformula,"")
– vivek
Jan 17 at 9:39
add a comment |
Split Cell Into Rows
Functions do not work in the way you described the possible functionality in your question, but here is a 'similar' VBA solution using the Worksheet Change Event.
Highlights
- In
Worksheet_Change
you can choose (provide) the Split Cell Range
Address containing the delimited data (cStrCell
) and the Split
Delimiter (cStrDel
). - When changing the data in the Split Cell Range, the solution will
copy the delimited data below the Split Cell Range into the
Split Data Range and delete all data below. - The change of any cell in the Split Data Range is not possible.
Copy the following code to the desired sheet code window e.g. Sheet1(Code).
The Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cStrCell As String = "A1" ' Split Cell Range Address
Const cStrDel As String = "," ' Split Delimiter
Application.EnableEvents = False
' Check if changed cell range is contained in Split Range.
If Not Intersect(Target, Range(cStrCell).Resize(UBound(Split( _
Range(cStrCell), cStrDel)) + 2)) Is Nothing Then
On Error GoTo ProcedureExit
' Check if changed cell range address
' is equal to Split Cell Range Address.
If Target.Address = Range(cStrCell).Address Then
' Clear contents of data below Split Range.
Range(Range(cStrCell).Offset(1), Cells(Rows.Count, _
Range(cStrCell).Column).End(xlUp)).ClearContents
End If
' Fill Split Range with Split Data
' i.e. copy Split Data below Split Cell Range.
SplitToRows Range(cStrCell), cStrDel
End If
ProcedureExit:
Application.EnableEvents = True
End Sub
Sub SplitToRows(SplitCellRange As Range, Optional Delimiter As String = ",")
Dim vntS As Variant ' Source Array
Dim vntT As Variant ' Target Array
Dim i As Long ' Arrays Row Counter
' Split first cell in SplitCellRange by Delimiter into Source Array.
vntS = Split(SplitCellRange.Cells(1, 1), Delimiter)
' Resize 2D one-based Target Array.
ReDim vntT(1 To UBound(vntS) + 1, 1 To 1)
' Trim and copy from Source to Target Array.
For i = 0 To UBound(vntS)
vntT(i + 1, 1) = Trim(vntS(i))
Next
' Copy Target Array to Target Range below SplitCellRange.
SplitCellRange.Cells(1, 1).Offset(1).Resize(UBound(vntT)) = vntT
End Sub
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
add a comment |
Split Cell Into Rows
Functions do not work in the way you described the possible functionality in your question, but here is a 'similar' VBA solution using the Worksheet Change Event.
Highlights
- In
Worksheet_Change
you can choose (provide) the Split Cell Range
Address containing the delimited data (cStrCell
) and the Split
Delimiter (cStrDel
). - When changing the data in the Split Cell Range, the solution will
copy the delimited data below the Split Cell Range into the
Split Data Range and delete all data below. - The change of any cell in the Split Data Range is not possible.
Copy the following code to the desired sheet code window e.g. Sheet1(Code).
The Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cStrCell As String = "A1" ' Split Cell Range Address
Const cStrDel As String = "," ' Split Delimiter
Application.EnableEvents = False
' Check if changed cell range is contained in Split Range.
If Not Intersect(Target, Range(cStrCell).Resize(UBound(Split( _
Range(cStrCell), cStrDel)) + 2)) Is Nothing Then
On Error GoTo ProcedureExit
' Check if changed cell range address
' is equal to Split Cell Range Address.
If Target.Address = Range(cStrCell).Address Then
' Clear contents of data below Split Range.
Range(Range(cStrCell).Offset(1), Cells(Rows.Count, _
Range(cStrCell).Column).End(xlUp)).ClearContents
End If
' Fill Split Range with Split Data
' i.e. copy Split Data below Split Cell Range.
SplitToRows Range(cStrCell), cStrDel
End If
ProcedureExit:
Application.EnableEvents = True
End Sub
Sub SplitToRows(SplitCellRange As Range, Optional Delimiter As String = ",")
Dim vntS As Variant ' Source Array
Dim vntT As Variant ' Target Array
Dim i As Long ' Arrays Row Counter
' Split first cell in SplitCellRange by Delimiter into Source Array.
vntS = Split(SplitCellRange.Cells(1, 1), Delimiter)
' Resize 2D one-based Target Array.
ReDim vntT(1 To UBound(vntS) + 1, 1 To 1)
' Trim and copy from Source to Target Array.
For i = 0 To UBound(vntS)
vntT(i + 1, 1) = Trim(vntS(i))
Next
' Copy Target Array to Target Range below SplitCellRange.
SplitCellRange.Cells(1, 1).Offset(1).Resize(UBound(vntT)) = vntT
End Sub
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
add a comment |
Split Cell Into Rows
Functions do not work in the way you described the possible functionality in your question, but here is a 'similar' VBA solution using the Worksheet Change Event.
Highlights
- In
Worksheet_Change
you can choose (provide) the Split Cell Range
Address containing the delimited data (cStrCell
) and the Split
Delimiter (cStrDel
). - When changing the data in the Split Cell Range, the solution will
copy the delimited data below the Split Cell Range into the
Split Data Range and delete all data below. - The change of any cell in the Split Data Range is not possible.
Copy the following code to the desired sheet code window e.g. Sheet1(Code).
The Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cStrCell As String = "A1" ' Split Cell Range Address
Const cStrDel As String = "," ' Split Delimiter
Application.EnableEvents = False
' Check if changed cell range is contained in Split Range.
If Not Intersect(Target, Range(cStrCell).Resize(UBound(Split( _
Range(cStrCell), cStrDel)) + 2)) Is Nothing Then
On Error GoTo ProcedureExit
' Check if changed cell range address
' is equal to Split Cell Range Address.
If Target.Address = Range(cStrCell).Address Then
' Clear contents of data below Split Range.
Range(Range(cStrCell).Offset(1), Cells(Rows.Count, _
Range(cStrCell).Column).End(xlUp)).ClearContents
End If
' Fill Split Range with Split Data
' i.e. copy Split Data below Split Cell Range.
SplitToRows Range(cStrCell), cStrDel
End If
ProcedureExit:
Application.EnableEvents = True
End Sub
Sub SplitToRows(SplitCellRange As Range, Optional Delimiter As String = ",")
Dim vntS As Variant ' Source Array
Dim vntT As Variant ' Target Array
Dim i As Long ' Arrays Row Counter
' Split first cell in SplitCellRange by Delimiter into Source Array.
vntS = Split(SplitCellRange.Cells(1, 1), Delimiter)
' Resize 2D one-based Target Array.
ReDim vntT(1 To UBound(vntS) + 1, 1 To 1)
' Trim and copy from Source to Target Array.
For i = 0 To UBound(vntS)
vntT(i + 1, 1) = Trim(vntS(i))
Next
' Copy Target Array to Target Range below SplitCellRange.
SplitCellRange.Cells(1, 1).Offset(1).Resize(UBound(vntT)) = vntT
End Sub
Split Cell Into Rows
Functions do not work in the way you described the possible functionality in your question, but here is a 'similar' VBA solution using the Worksheet Change Event.
Highlights
- In
Worksheet_Change
you can choose (provide) the Split Cell Range
Address containing the delimited data (cStrCell
) and the Split
Delimiter (cStrDel
). - When changing the data in the Split Cell Range, the solution will
copy the delimited data below the Split Cell Range into the
Split Data Range and delete all data below. - The change of any cell in the Split Data Range is not possible.
Copy the following code to the desired sheet code window e.g. Sheet1(Code).
The Code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const cStrCell As String = "A1" ' Split Cell Range Address
Const cStrDel As String = "," ' Split Delimiter
Application.EnableEvents = False
' Check if changed cell range is contained in Split Range.
If Not Intersect(Target, Range(cStrCell).Resize(UBound(Split( _
Range(cStrCell), cStrDel)) + 2)) Is Nothing Then
On Error GoTo ProcedureExit
' Check if changed cell range address
' is equal to Split Cell Range Address.
If Target.Address = Range(cStrCell).Address Then
' Clear contents of data below Split Range.
Range(Range(cStrCell).Offset(1), Cells(Rows.Count, _
Range(cStrCell).Column).End(xlUp)).ClearContents
End If
' Fill Split Range with Split Data
' i.e. copy Split Data below Split Cell Range.
SplitToRows Range(cStrCell), cStrDel
End If
ProcedureExit:
Application.EnableEvents = True
End Sub
Sub SplitToRows(SplitCellRange As Range, Optional Delimiter As String = ",")
Dim vntS As Variant ' Source Array
Dim vntT As Variant ' Target Array
Dim i As Long ' Arrays Row Counter
' Split first cell in SplitCellRange by Delimiter into Source Array.
vntS = Split(SplitCellRange.Cells(1, 1), Delimiter)
' Resize 2D one-based Target Array.
ReDim vntT(1 To UBound(vntS) + 1, 1 To 1)
' Trim and copy from Source to Target Array.
For i = 0 To UBound(vntS)
vntT(i + 1, 1) = Trim(vntS(i))
Next
' Copy Target Array to Target Range below SplitCellRange.
SplitCellRange.Cells(1, 1).Offset(1).Resize(UBound(vntT)) = vntT
End Sub
answered Jan 17 at 10:42
VBasic2008VBasic2008
1013
1013
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
add a comment |
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
Dear All. Thank you very much your answers. The marked answer is more easier for me.
– Domdamo
Jan 17 at 19:44
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395255%2fsplit-cell-content-into-multiple-separate-rows-in-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I can do it with Python, although it can probably also be done with VBA. Perhaps instead of typing those Comma Separated values into Excel, you could put them into a text file with a .CSV extension and import it?
– Mawg
Jan 17 at 7:38
1
I can't think of an easy way of doing this in a single step but it feels like you could use Excel's built in Text to Columns feature then use Copy> Paste Special>Transpose to get into into rows depending on the volume of data
– RickyTillson
Jan 17 at 8:40
1
On the DATA tab you can use "Text to Columns" to do this.
– Kevin Anthony Oppegaard Rose
Jan 17 at 9:56