View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default convert to specific format

True,

Select a cell in your two columns and run the macro below, then copy and transpose the resulting
table.

HTH,
Bernie
MS Excel MVP

Sub DBtoCrossTab()
Dim myCell As Range
Dim myTable As Range
Dim mySht As Worksheet
Dim myRow As Long

Set myTable = ActiveCell.CurrentRegion

On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Cross Tab").Delete
Application.DisplayAlerts = True

Set mySht = Worksheets.Add
mySht.Name = "Cross Tab"

myTable.Rows(1).EntireRow.Copy mySht.Rows(1)

Set myTable = myTable.Offset(1, 0).Resize _
(myTable.Rows.Count - 1, myTable.Columns.Count)

For Each myCell In myTable.Columns(1).Cells
If IsError(Application.Match(myCell.Value, _
mySht.Range("A:A"), False)) Then
myCell.EntireRow.Copy _
mySht.Range("A65536").End(xlUp)(2).EntireRow
Else
myRow = Application.Match(myCell.Value, _
mySht.Range("A:A"), False)
myCell.Offset(0, 1).Resize(1, myTable.Columns.Count - 1).Copy _
mySht.Cells(myRow, 256).End(xlToLeft)(1, 2)
End If
Next myCell

End Sub



"true_atlantis" wrote in message
news:true_atlantis.25ggtn_1143676501.7328@excelfor um-nospam.com...

lets say i have two columns like this...

aa 54
aa 45
bb 12
bb 18
bb 12
cc 13

how can i convert that to a chart like


Code:
--------------------
aa bb cc
54 12 13
45 18
12
--------------------


thanks


--
true_atlantis
------------------------------------------------------------------------
true_atlantis's Profile: http://www.excelforum.com/member.php...o&userid=32957
View this thread: http://www.excelforum.com/showthread...hreadid=527879