#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default transpose data

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default transpose data

Hi,

If I understand your requirements correctly try this. Because it deletes
data try on a test workbook first. Right click the sheet tab, view code and
paste this in and run it.

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow Step 2
Cells(x, 1).Offset(-1, 1).Value = Cells(x, 1).Value
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, 2)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, 2))
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default transpose data

Thank You Very much indeed Mike,
I think I didn't make myself understood,
I am trying to covert a Column into as many Columns as there is Data:

From:
1
1
2
2
2
3
4
4

To (Multiple Columns):
1 1 (Entry "1" appears 2x)
2 2 2 (Entry "2" appears 3x)
3 (Entry "3" appears 1x)
4 4 (Entry "4" appears 2x)
Etcetera.
Any help is Greatly appreciated.
Many Thanks,
Hilvert

"Mike H" wrote:

Hi,

If I understand your requirements correctly try this. Because it deletes
data try on a test workbook first. Right click the sheet tab, view code and
paste this in and run it.

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow Step 2
Cells(x, 1).Offset(-1, 1).Value = Cells(x, 1).Value
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, 2)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, 2))
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default transpose data

Hi,

A bit more involved bit I think we got there

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Max = Application.WorksheetFunction.CountIf(Range("A1:A" & lastrow), _
Application.WorksheetFunction.Mode(Range("A1:A" & lastrow)))
col = 1
oset = -1
For x = 2 To lastrow
If Cells(x, 1).Value = Cells(x - 1, 1).Value Then
Cells(x, 1).Offset(oset, col).Value = Cells(x, 1).Value
col = col + 1
oset = oset - 1
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, Max)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, Max))
End If
Else
col = 1
oset = -1
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Thank You Very much indeed Mike,
I think I didn't make myself understood,
I am trying to covert a Column into as many Columns as there is Data:

From:
1
1
2
2
2
3
4
4

To (Multiple Columns):
1 1 (Entry "1" appears 2x)
2 2 2 (Entry "2" appears 3x)
3 (Entry "3" appears 1x)
4 4 (Entry "4" appears 2x)
Etcetera.
Any help is Greatly appreciated.
Many Thanks,
Hilvert

"Mike H" wrote:

Hi,

If I understand your requirements correctly try this. Because it deletes
data try on a test workbook first. Right click the sheet tab, view code and
paste this in and run it.

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow Step 2
Cells(x, 1).Offset(-1, 1).Value = Cells(x, 1).Value
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, 2)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, 2))
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default transpose data

Many Thanks Mike,
That's a Great help!!!
Hilvert

"Mike H" wrote:

Hi,

A bit more involved bit I think we got there

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Max = Application.WorksheetFunction.CountIf(Range("A1:A" & lastrow), _
Application.WorksheetFunction.Mode(Range("A1:A" & lastrow)))
col = 1
oset = -1
For x = 2 To lastrow
If Cells(x, 1).Value = Cells(x - 1, 1).Value Then
Cells(x, 1).Offset(oset, col).Value = Cells(x, 1).Value
col = col + 1
oset = oset - 1
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, Max)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, Max))
End If
Else
col = 1
oset = -1
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Thank You Very much indeed Mike,
I think I didn't make myself understood,
I am trying to covert a Column into as many Columns as there is Data:

From:
1
1
2
2
2
3
4
4

To (Multiple Columns):
1 1 (Entry "1" appears 2x)
2 2 2 (Entry "2" appears 3x)
3 (Entry "3" appears 1x)
4 4 (Entry "4" appears 2x)
Etcetera.
Any help is Greatly appreciated.
Many Thanks,
Hilvert

"Mike H" wrote:

Hi,

If I understand your requirements correctly try this. Because it deletes
data try on a test workbook first. Right click the sheet tab, view code and
paste this in and run it.

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow Step 2
Cells(x, 1).Offset(-1, 1).Value = Cells(x, 1).Value
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, 2)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, 2))
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default transpose data

Your welcome and thanks for the feedback

"Hilvert Scheper" wrote:

Many Thanks Mike,
That's a Great help!!!
Hilvert

"Mike H" wrote:

Hi,

A bit more involved bit I think we got there

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Max = Application.WorksheetFunction.CountIf(Range("A1:A" & lastrow), _
Application.WorksheetFunction.Mode(Range("A1:A" & lastrow)))
col = 1
oset = -1
For x = 2 To lastrow
If Cells(x, 1).Value = Cells(x - 1, 1).Value Then
Cells(x, 1).Offset(oset, col).Value = Cells(x, 1).Value
col = col + 1
oset = oset - 1
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, Max)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, Max))
End If
Else
col = 1
oset = -1
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Thank You Very much indeed Mike,
I think I didn't make myself understood,
I am trying to covert a Column into as many Columns as there is Data:

From:
1
1
2
2
2
3
4
4

To (Multiple Columns):
1 1 (Entry "1" appears 2x)
2 2 2 (Entry "2" appears 3x)
3 (Entry "3" appears 1x)
4 4 (Entry "4" appears 2x)
Etcetera.
Any help is Greatly appreciated.
Many Thanks,
Hilvert

"Mike H" wrote:

Hi,

If I understand your requirements correctly try this. Because it deletes
data try on a test workbook first. Right click the sheet tab, view code and
paste this in and run it.

Sub transpose()
Dim deleterange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow Step 2
Cells(x, 1).Offset(-1, 1).Value = Cells(x, 1).Value
If deleterange Is Nothing Then
Set deleterange = Cells(x, 1).Resize(, 2)
Else
Set deleterange = Union(deleterange, Cells(x, 1).Resize(, 2))
End If
Next
If Not deleterange Is Nothing Then
deleterange.Delete Shift:=xlUp
End If
End Sub

Mike

"Hilvert Scheper" wrote:

Hi There,
I would really appreciate some help on the next subject:
How do I transpose This:
1
1
2
2
3
3

To:
1 1
2 2
3 3

This is a (Combined?) Transpose of 1 Column into Rows, where the data
decides how many Columns I need....

Many Thanks in advance!!!

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 data Nenagh Excel Discussion (Misc queries) 1 January 16th 08 05:22 AM
Transpose certain data BCLivell Excel Discussion (Misc queries) 1 November 7th 06 11:37 PM
transpose data KK New Users to Excel 3 October 22nd 06 02:43 AM
transpose data srinivasan Excel Discussion (Misc queries) 7 February 17th 06 02:49 PM
transpose data babs Excel Worksheet Functions 2 December 7th 04 11:49 PM


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