PC Review


Reply
Thread Tools Rate Thread

Breaking a row into multiple rows

 
 
=?Utf-8?B?WW9zcy0yMg==?=
Guest
Posts: n/a
 
      11th Nov 2007
I have a table like this:

Name ID Type
A 12; 14 New
B 13; 15 Old

I want to convert this to:

Name ID Type
A 12 New
A 14 New
B 13 Old
B 15 Old


 
Reply With Quote
 
 
 
 
Tim Zych
Guest
Posts: n/a
 
      11th Nov 2007
Dim cell As Range
Dim rng As Range
Dim v As Variant, i As Integer
Dim wksNew As Worksheet
Set rng = Range("B2:B4")
Set wksNew = Workbooks.Add(1).Worksheets(1)
For Each cell In rng.Cells
v = Split(cell.Value, ";")
For i = LBound(v) To UBound(v)
With wksNew.Cells(65000, "A").End(xlUp).Offset(1)
.Cells(1, 1).Value = cell.Offset(, -1).Value
.Cells(1, 2).Value = Trim(v(i))
.Cells(1, 3).Value = cell.Offset(, 1).Value
End With
Next
Next

Adjust the rng setting to be the proper semicolon-delimited list.

--
Tim Zych
SF, CA


"Yoss-22" <Yoss-(E-Mail Removed)> wrote in message
news:2CE6F597-7EFF-45F5-9FE8-(E-Mail Removed)...
>I have a table like this:
>
> Name ID Type
> A 12; 14 New
> B 13; 15 Old
>
> I want to convert this to:
>
> Name ID Type
> A 12 New
> A 14 New
> B 13 Old
> B 15 Old
>
>



 
Reply With Quote
 
=?Utf-8?B?WW9zcy0yMg==?=
Guest
Posts: n/a
 
      11th Nov 2007
Thanks, that helps.

"Tim Zych" wrote:

> Dim cell As Range
> Dim rng As Range
> Dim v As Variant, i As Integer
> Dim wksNew As Worksheet
> Set rng = Range("B2:B4")
> Set wksNew = Workbooks.Add(1).Worksheets(1)
> For Each cell In rng.Cells
> v = Split(cell.Value, ";")
> For i = LBound(v) To UBound(v)
> With wksNew.Cells(65000, "A").End(xlUp).Offset(1)
> .Cells(1, 1).Value = cell.Offset(, -1).Value
> .Cells(1, 2).Value = Trim(v(i))
> .Cells(1, 3).Value = cell.Offset(, 1).Value
> End With
> Next
> Next
>
> Adjust the rng setting to be the proper semicolon-delimited list.
>
> --
> Tim Zych
> SF, CA
>
>
> "Yoss-22" <Yoss-(E-Mail Removed)> wrote in message
> news:2CE6F597-7EFF-45F5-9FE8-(E-Mail Removed)...
> >I have a table like this:
> >
> > Name ID Type
> > A 12; 14 New
> > B 13; 15 Old
> >
> > I want to convert this to:
> >
> > Name ID Type
> > A 12 New
> > A 14 New
> > B 13 Old
> > B 15 Old
> >
> >

>
>
>

 
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
Breaking up one field into 2 columns and 2 rows Matt Williamson Microsoft Access Reports 0 11th Mar 2010 09:47 PM
rows breaking over pages holden Microsoft Word Document Management 4 26th Jan 2010 09:19 PM
Breaking out rows of data, sequentially, into headered columns Randy Microsoft Excel Programming 3 26th Dec 2009 03:53 AM
Macro for Breaking out Rows cardan Microsoft Excel Programming 2 18th Oct 2006 04:18 PM
Breaking Table Rows Across Page =?Utf-8?B?SmFtaWUgQSBNaWxsZXI=?= Microsoft Word Document Management 2 18th Sep 2006 02:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:10 PM.