Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Transpose a variable length list

I'm attempting to convert this list..

Column1 Colum2
Bob Apple
Orange
Bannana
Tom Grape
Strawberry
Bill Coconut
Mary Pineapple
Watermellon
etc....

Into this format....

Column1 Column2
Bob Apple, Orange, Bannana
Tom Grape, Strawberry
Bill Coconut
Mary Pineapple, Watermellon

Any help would be appreciated!!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Transpose a variable length list

Do this against a copy of your workbook--or close without saving. It destroys
the original data:

Option Explicit
Sub testme02()
Dim wks As Worksheet
Dim LastRow As Long
Dim FirstRow As Long
Dim iRow As Long

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For iRow = LastRow To FirstRow + 1 Step -1
If Trim(.Cells(iRow, "A").Value) = "" Then
.Cells(iRow - 1, "B").Value = .Cells(iRow - 1, "B").Value _
& "," & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With
End Sub




wrote:

I'm attempting to convert this list..

Column1 Colum2
Bob Apple
Orange
Bannana
Tom Grape
Strawberry
Bill Coconut
Mary Pineapple
Watermellon
etc....

Into this format....

Column1 Column2
Bob Apple, Orange, Bannana
Tom Grape, Strawberry
Bill Coconut
Mary Pineapple, Watermellon

Any help would be appreciated!!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Transpose a variable length list

Try one of these two macros:
Sub ToRow2()
With ActiveCell
.Offset(1, 0).Resize(9, 1).Copy
.Offset(0, 1).PasteSpecial Transpose:=True
End With
End Sub

Sub ToRow()
With ActiveCell
.Resize(9, 1).Copy
.Offset(0, 1).PasteSpecial Transpose:=True
End With
End Sub

Regards,
Ryan--

--
RyGuy


"Dave Peterson" wrote:

Do this against a copy of your workbook--or close without saving. It destroys
the original data:

Option Explicit
Sub testme02()
Dim wks As Worksheet
Dim LastRow As Long
Dim FirstRow As Long
Dim iRow As Long

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For iRow = LastRow To FirstRow + 1 Step -1
If Trim(.Cells(iRow, "A").Value) = "" Then
.Cells(iRow - 1, "B").Value = .Cells(iRow - 1, "B").Value _
& "," & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With
End Sub




wrote:

I'm attempting to convert this list..

Column1 Colum2
Bob Apple
Orange
Bannana
Tom Grape
Strawberry
Bill Coconut
Mary Pineapple
Watermellon
etc....

Into this format....

Column1 Column2
Bob Apple, Orange, Bannana
Tom Grape, Strawberry
Bill Coconut
Mary Pineapple, Watermellon

Any help would be appreciated!!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Transpose a variable length list

This won't work for the OP's original data.

That size of each group was variable.

ryguy7272 wrote:

Try one of these two macros:
Sub ToRow2()
With ActiveCell
.Offset(1, 0).Resize(9, 1).Copy
.Offset(0, 1).PasteSpecial Transpose:=True
End With
End Sub

Sub ToRow()
With ActiveCell
.Resize(9, 1).Copy
.Offset(0, 1).PasteSpecial Transpose:=True
End With
End Sub

Regards,
Ryan--

--
RyGuy

"Dave Peterson" wrote:

Do this against a copy of your workbook--or close without saving. It destroys
the original data:

Option Explicit
Sub testme02()
Dim wks As Worksheet
Dim LastRow As Long
Dim FirstRow As Long
Dim iRow As Long

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For iRow = LastRow To FirstRow + 1 Step -1
If Trim(.Cells(iRow, "A").Value) = "" Then
.Cells(iRow - 1, "B").Value = .Cells(iRow - 1, "B").Value _
& "," & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With
End Sub




wrote:

I'm attempting to convert this list..

Column1 Colum2
Bob Apple
Orange
Bannana
Tom Grape
Strawberry
Bill Coconut
Mary Pineapple
Watermellon
etc....

Into this format....

Column1 Column2
Bob Apple, Orange, Bannana
Tom Grape, Strawberry
Bill Coconut
Mary Pineapple, Watermellon

Any help would be appreciated!!


--

Dave Peterson


--

Dave Peterson
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
Transpose random length series of cells [email protected] Excel Worksheet Functions 7 November 17th 08 08:34 PM
Transpose a variable length list into Excel / Access Table Pete New Users to Excel 11 September 13th 06 07:37 PM
Create Variable Length String Dependent Upon Size List ags5406 Excel Programming 1 May 28th 06 11:30 PM
Filling combobox with variable length list Denny Behnfeldt Excel Programming 3 January 2nd 05 06:31 PM
how to? running average from a variable length list robreeve Excel Programming 1 July 28th 03 02:05 PM


All times are GMT +1. The time now is 12:48 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"