Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Splitting records

Hi everybody,

I need some help to enable me working smarter and faster. I have a list
consisting of three columns which I need to convert in multiple rows as
follows.

A B C D
Tommy 500 75 575
Peter 100 15 115
Jane 800 120 920
Greg 200 30 230

The list should look as follows as it requires further processing

Tommy 500
Tommy 75
Tommy 575
Peter 100
Peter 15
Peter 115
Jane 800
Jane 120
Jane 920

The list may vary in number of lines.

Thank you for your guidance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Splitting records

This assume the original data is in Sheet1 and the output will be put in
Sheet2:

Sub settupp()
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
s1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
namee = Cells(i, 1).Value
For j = 2 To 4
numberr = Cells(i, j).Value
s2.Cells(k, 1) = namee
s2.Cells(k, 2) = numberr
k = k + 1
Next
Next
End Sub

Adjust the names to suit your needs.
--
Gary''s Student - gsnu200836


"wins007" wrote:

Hi everybody,

I need some help to enable me working smarter and faster. I have a list
consisting of three columns which I need to convert in multiple rows as
follows.

A B C D
Tommy 500 75 575
Peter 100 15 115
Jane 800 120 920
Greg 200 30 230

The list should look as follows as it requires further processing

Tommy 500
Tommy 75
Tommy 575
Peter 100
Peter 15
Peter 115
Jane 800
Jane 120
Jane 920

The list may vary in number of lines.

Thank you for your guidance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Splitting records

Thank you mate, it works perfectly

"Gary''s Student" wrote:

This assume the original data is in Sheet1 and the output will be put in
Sheet2:

Sub settupp()
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
s1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
namee = Cells(i, 1).Value
For j = 2 To 4
numberr = Cells(i, j).Value
s2.Cells(k, 1) = namee
s2.Cells(k, 2) = numberr
k = k + 1
Next
Next
End Sub

Adjust the names to suit your needs.
--
Gary''s Student - gsnu200836


"wins007" wrote:

Hi everybody,

I need some help to enable me working smarter and faster. I have a list
consisting of three columns which I need to convert in multiple rows as
follows.

A B C D
Tommy 500 75 575
Peter 100 15 115
Jane 800 120 920
Greg 200 30 230

The list should look as follows as it requires further processing

Tommy 500
Tommy 75
Tommy 575
Peter 100
Peter 15
Peter 115
Jane 800
Jane 120
Jane 920

The list may vary in number of lines.

Thank you for your guidance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Splitting records

This code will Let you go back again:
Sub newlist()
Set w1 = Sheets("Sheet1")
Set w2 = Sheets("Sheet2")
w2.Cells(1, 1).Value = w1.Cells(1, 1).Value
w2.Cells(1, 2).Value = w1.Cells(1, 2).Value
Ide = Cells(1, 1).Value
w1.Activate
n = Cells(Rows.count, 1).End(xlUp).Row
k = 3
kk = 1
For i = 2 To n
If w1.Cells(i, 1).Value = Ide Then
w2.Cells(kk, k).Value = w1.Cells(i, 2).Value
k = k + 1
Else
kk = kk + 1
k = 3
Ide = w1.Cells(i, 1).Value
w2.Cells(kk, 1).Value = Ide
w2.Cells(kk, 2).Value = w1.Cells(i, 2).Value
End If
Next
End Sub


Regards,
Ryan---
--
RyGuy


"wins007" wrote:

Thank you mate, it works perfectly

"Gary''s Student" wrote:

This assume the original data is in Sheet1 and the output will be put in
Sheet2:

Sub settupp()
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
s1.Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
namee = Cells(i, 1).Value
For j = 2 To 4
numberr = Cells(i, j).Value
s2.Cells(k, 1) = namee
s2.Cells(k, 2) = numberr
k = k + 1
Next
Next
End Sub

Adjust the names to suit your needs.
--
Gary''s Student - gsnu200836


"wins007" wrote:

Hi everybody,

I need some help to enable me working smarter and faster. I have a list
consisting of three columns which I need to convert in multiple rows as
follows.

A B C D
Tommy 500 75 575
Peter 100 15 115
Jane 800 120 920
Greg 200 30 230

The list should look as follows as it requires further processing

Tommy 500
Tommy 75
Tommy 575
Peter 100
Peter 15
Peter 115
Jane 800
Jane 120
Jane 920

The list may vary in number of lines.

Thank you for your guidance.

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
Delete records when certain records have duplicate column data JVroom New Users to Excel 1 January 26th 09 06:23 PM
Using vb to paste records from 1 sheet, to related records in another chrisnichols87 Excel Programming 0 January 10th 07 10:59 AM
Splitting appointment records in to 15 minute time bands The Inquirer Excel Worksheet Functions 4 October 9th 06 02:38 PM
Splitting appointment records in to 15 minute time bands The Inquirer Excel Discussion (Misc queries) 3 October 9th 06 12:30 PM
draw 999 x 8 random records from file with 8614 records news.wanadoo.nl Excel Programming 1 March 1st 06 03:04 PM


All times are GMT +1. The time now is 07:06 AM.

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"