Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Breaking a row into multiple rows

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Breaking a row into multiple rows

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" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Breaking a row into multiple rows

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted breaking up of print output into multiple files Atreides Setting up and Configuration of Excel 4 August 15th 08 08:18 PM
Breaking tie breakers using multiple colmns [email protected] Excel Worksheet Functions 15 March 22nd 07 09:15 PM
Macro for Breaking out Rows cardan Excel Programming 2 October 18th 06 04:18 PM
Breaking a workbook into multiple books Doug Lowe Excel Programming 2 June 20th 06 09:47 PM
split text in one cell into multiple cells without breaking the wo Prashant Excel Worksheet Functions 3 March 6th 06 08:48 AM


All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"