PC Review


Reply
Thread Tools Rate Thread

Converting data into multiple rows

 
 
Kathleen_TX
Guest
Posts: n/a
 
      19th May 2009
I have a spreadsheet of raw data with several columns. One of the columns
contains multiple market segments separated by commas (Chemicals, Specialty
Chemicals, Polymers, etc). I want to break out each row into multiple rows
based on however many market segments there are. For example, one row of data
may have 6 market segments. I want to convert that row of data into 6 rows of
data, one per market segment. Is there an easy way to do this? I have 1000+
rows of data, so doing this manually is extremely painful.
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      19th May 2009
Kathleen,

First ensure you have sufficient empty columns to the right of your column
of data to split the data into then:

Data|Text to columns - delimited - next - select comma - finish


Mike

"Kathleen_TX" wrote:

> I have a spreadsheet of raw data with several columns. One of the columns
> contains multiple market segments separated by commas (Chemicals, Specialty
> Chemicals, Polymers, etc). I want to break out each row into multiple rows
> based on however many market segments there are. For example, one row of data
> may have 6 market segments. I want to convert that row of data into 6 rows of
> data, one per market segment. Is there an easy way to do this? I have 1000+
> rows of data, so doing this manually is extremely painful.

 
Reply With Quote
 
Kathleen_TX
Guest
Posts: n/a
 
      19th May 2009
Thanks Mike. I tried that, but that's not exactly what I'm trying to do. I
want to break out the entire row of data into multiple rows.

"Mike H" wrote:

> Kathleen,
>
> First ensure you have sufficient empty columns to the right of your column
> of data to split the data into then:
>
> Data|Text to columns - delimited - next - select comma - finish
>
>
> Mike
>
> "Kathleen_TX" wrote:
>
> > I have a spreadsheet of raw data with several columns. One of the columns
> > contains multiple market segments separated by commas (Chemicals, Specialty
> > Chemicals, Polymers, etc). I want to break out each row into multiple rows
> > based on however many market segments there are. For example, one row of data
> > may have 6 market segments. I want to convert that row of data into 6 rows of
> > data, one per market segment. Is there an easy way to do this? I have 1000+
> > rows of data, so doing this manually is extremely painful.

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      19th May 2009
this sub checks the contents of column C and adds new rows for each item if
theres a cell with more than one item comma separated

Option Explicit
Sub breakup()
Dim cell As Range
Dim rownum As Long
Dim data As Variant
Dim index As Long
'insert from bottom to top
'get the last row
rownum = Range("C1").End(xlDown).Row
For rownum = rownum To 2 Step -1
If InStr(Cells(rownum, "C").Value, ",") > 0 Then
data = Split(Cells(rownum, "C"), ",")
For index = 0 To UBound(data, 1)
Rows(rownum + 1).Insert
Cells(rownum + 1, "C") = data(index)
Next
Rows(rownum).Delete
End If
Next
End Sub

"Kathleen_TX" <(E-Mail Removed)> wrote in message
news:EF03A1BB-93ED-42A4-831D-(E-Mail Removed)...
>I have a spreadsheet of raw data with several columns. One of the columns
> contains multiple market segments separated by commas (Chemicals,
> Specialty
> Chemicals, Polymers, etc). I want to break out each row into multiple rows
> based on however many market segments there are. For example, one row of
> data
> may have 6 market segments. I want to convert that row of data into 6 rows
> of
> data, one per market segment. Is there an easy way to do this? I have
> 1000+
> rows of data, so doing this manually is extremely painful.


 
Reply With Quote
 
Kathleen_TX
Guest
Posts: n/a
 
      19th May 2009
Thanks Patrick. I think we must be close. The sub created new rows with
column C split out, but the rest of the row data wasn't replicated.

In this spreadsheet I have several columns of data - Title, Description,
Click Here, Market Segment, Business Area, Application, Product, etc. The
Market Segment column has multiple entries separated by commas. I need the
entire row replicated x number of times based on how many entries are in the
Market column, with a single market per row.

"Patrick Molloy" wrote:

> this sub checks the contents of column C and adds new rows for each item if
> theres a cell with more than one item comma separated
>
> Option Explicit
> Sub breakup()
> Dim cell As Range
> Dim rownum As Long
> Dim data As Variant
> Dim index As Long
> 'insert from bottom to top
> 'get the last row
> rownum = Range("C1").End(xlDown).Row
> For rownum = rownum To 2 Step -1
> If InStr(Cells(rownum, "C").Value, ",") > 0 Then
> data = Split(Cells(rownum, "C"), ",")
> For index = 0 To UBound(data, 1)
> Rows(rownum + 1).Insert
> Cells(rownum + 1, "C") = data(index)
> Next
> Rows(rownum).Delete
> End If
> Next
> End Sub
>
> "Kathleen_TX" <(E-Mail Removed)> wrote in message
> news:EF03A1BB-93ED-42A4-831D-(E-Mail Removed)...
> >I have a spreadsheet of raw data with several columns. One of the columns
> > contains multiple market segments separated by commas (Chemicals,
> > Specialty
> > Chemicals, Polymers, etc). I want to break out each row into multiple rows
> > based on however many market segments there are. For example, one row of
> > data
> > may have 6 market segments. I want to convert that row of data into 6 rows
> > of
> > data, one per market segment. Is there an easy way to do this? I have
> > 1000+
> > rows of data, so doing this manually is extremely painful.

>
>

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      20th May 2009
ok. when the row is added , replicate the data before updating the value in
C

Option Explicit
Sub breakup()
Dim cell As Range
Dim rownum As Long
Dim data As Variant
Dim index As Long
'insert from bottom to top
'get the last row
rownum = Range("C1").End(xlDown).Row
For rownum = rownum To 2 Step -1
If InStr(Cells(rownum, "C").Value, ",") > 0 Then
data = Split(Cells(rownum, "C"), ",")
For index = 0 To UBound(data, 1)
Rows(rownum + 1).Insert

Rows(rownum).Copy
Rows(rownum + 1).PasteSpecial xlAll

Cells(rownum + 1, "C") = data(index)
Next
Rows(rownum).Delete
End If
Next
End Sub



"Kathleen_TX" <(E-Mail Removed)> wrote in message
news:26815D3C-7AD4-4B44-BF5B-(E-Mail Removed)...
> Thanks Patrick. I think we must be close. The sub created new rows with
> column C split out, but the rest of the row data wasn't replicated.
>
> In this spreadsheet I have several columns of data - Title, Description,
> Click Here, Market Segment, Business Area, Application, Product, etc. The
> Market Segment column has multiple entries separated by commas. I need the
> entire row replicated x number of times based on how many entries are in
> the
> Market column, with a single market per row.
>
> "Patrick Molloy" wrote:
>
>> this sub checks the contents of column C and adds new rows for each item
>> if
>> theres a cell with more than one item comma separated
>>
>> Option Explicit
>> Sub breakup()
>> Dim cell As Range
>> Dim rownum As Long
>> Dim data As Variant
>> Dim index As Long
>> 'insert from bottom to top
>> 'get the last row
>> rownum = Range("C1").End(xlDown).Row
>> For rownum = rownum To 2 Step -1
>> If InStr(Cells(rownum, "C").Value, ",") > 0 Then
>> data = Split(Cells(rownum, "C"), ",")
>> For index = 0 To UBound(data, 1)
>> Rows(rownum + 1).Insert
>> Cells(rownum + 1, "C") = data(index)
>> Next
>> Rows(rownum).Delete
>> End If
>> Next
>> End Sub
>>
>> "Kathleen_TX" <(E-Mail Removed)> wrote in message
>> news:EF03A1BB-93ED-42A4-831D-(E-Mail Removed)...
>> >I have a spreadsheet of raw data with several columns. One of the
>> >columns
>> > contains multiple market segments separated by commas (Chemicals,
>> > Specialty
>> > Chemicals, Polymers, etc). I want to break out each row into multiple
>> > rows
>> > based on however many market segments there are. For example, one row
>> > of
>> > data
>> > may have 6 market segments. I want to convert that row of data into 6
>> > rows
>> > of
>> > data, one per market segment. Is there an easy way to do this? I have
>> > 1000+
>> > rows of data, so doing this manually is extremely painful.

>>
>>

 
Reply With Quote
 
Kathleen_TX
Guest
Posts: n/a
 
      20th May 2009
Thanks Patrick.

"Patrick Molloy" wrote:

> ok. when the row is added , replicate the data before updating the value in
> C
>
> Option Explicit
> Sub breakup()
> Dim cell As Range
> Dim rownum As Long
> Dim data As Variant
> Dim index As Long
> 'insert from bottom to top
> 'get the last row
> rownum = Range("C1").End(xlDown).Row
> For rownum = rownum To 2 Step -1
> If InStr(Cells(rownum, "C").Value, ",") > 0 Then
> data = Split(Cells(rownum, "C"), ",")
> For index = 0 To UBound(data, 1)
> Rows(rownum + 1).Insert
>
> Rows(rownum).Copy
> Rows(rownum + 1).PasteSpecial xlAll
>
> Cells(rownum + 1, "C") = data(index)
> Next
> Rows(rownum).Delete
> End If
> Next
> End Sub
>
>
>
> "Kathleen_TX" <(E-Mail Removed)> wrote in message
> news:26815D3C-7AD4-4B44-BF5B-(E-Mail Removed)...
> > Thanks Patrick. I think we must be close. The sub created new rows with
> > column C split out, but the rest of the row data wasn't replicated.
> >
> > In this spreadsheet I have several columns of data - Title, Description,
> > Click Here, Market Segment, Business Area, Application, Product, etc. The
> > Market Segment column has multiple entries separated by commas. I need the
> > entire row replicated x number of times based on how many entries are in
> > the
> > Market column, with a single market per row.
> >
> > "Patrick Molloy" wrote:
> >
> >> this sub checks the contents of column C and adds new rows for each item
> >> if
> >> theres a cell with more than one item comma separated
> >>
> >> Option Explicit
> >> Sub breakup()
> >> Dim cell As Range
> >> Dim rownum As Long
> >> Dim data As Variant
> >> Dim index As Long
> >> 'insert from bottom to top
> >> 'get the last row
> >> rownum = Range("C1").End(xlDown).Row
> >> For rownum = rownum To 2 Step -1
> >> If InStr(Cells(rownum, "C").Value, ",") > 0 Then
> >> data = Split(Cells(rownum, "C"), ",")
> >> For index = 0 To UBound(data, 1)
> >> Rows(rownum + 1).Insert
> >> Cells(rownum + 1, "C") = data(index)
> >> Next
> >> Rows(rownum).Delete
> >> End If
> >> Next
> >> End Sub
> >>
> >> "Kathleen_TX" <(E-Mail Removed)> wrote in message
> >> news:EF03A1BB-93ED-42A4-831D-(E-Mail Removed)...
> >> >I have a spreadsheet of raw data with several columns. One of the
> >> >columns
> >> > contains multiple market segments separated by commas (Chemicals,
> >> > Specialty
> >> > Chemicals, Polymers, etc). I want to break out each row into multiple
> >> > rows
> >> > based on however many market segments there are. For example, one row
> >> > of
> >> > data
> >> > may have 6 market segments. I want to convert that row of data into 6
> >> > rows
> >> > of
> >> > data, one per market segment. Is there an easy way to do this? I have
> >> > 1000+
> >> > rows of data, so doing this manually is extremely painful.
> >>
> >>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting multiple rows of Excel data into Word Document Joel Microsoft Excel Misc 1 16th Jan 2010 09:14 AM
Converting multiple rows into columns =?Utf-8?B?SmFjaw==?= Microsoft Excel Misc 3 12th Oct 2007 12:07 PM
Need help with Converting Rows of data into 2 columns Steve Microsoft Excel Worksheet Functions 3 11th Aug 2005 04:41 AM
Converting Rows of Data to Columns Greg Flowers Microsoft Excel Discussion 3 8th Mar 2005 08:43 PM
Converting rows of data into columns Ian McD Wood Microsoft Excel Misc 1 17th Aug 2004 07:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:33 AM.