LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Transpose Crosstab Data in Excel 2000 to flat file for use in

How about a little macro:

Option Explicit
Sub testme()

Dim CurWks As Worksheet
Dim NewWks As Worksheet

Dim oRow As Long
Dim HowManyCols As Long

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long

Dim iCol As Long
Dim FirstCol As Long
Dim LastCol As Long

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets.Add

With CurWks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

FirstCol = 3
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column

HowManyCols = LastCol - FirstCol + 1

NewWks.Range("a1").Resize(1, 4).Value _
= Array("Area", "Category", "Date", "Qty")

oRow = 2
For iRow = FirstRow To LastRow
NewWks.Cells(oRow, "A").Resize(HowManyCols, 1).Value _
= .Cells(iRow, "A").Value
NewWks.Cells(oRow, "B").Resize(HowManyCols, 1).Value _
= .Cells(iRow, "B").Value
NewWks.Cells(oRow, "C").Resize(HowManyCols, 1).Value _
= Application.Transpose(.Range("c1").Resize(1, HowManyCols))
NewWks.Cells(oRow, "d").Resize(HowManyCols, 1).Value _
= Application.Transpose(.Cells(iRow, "c").Resize(1, HowManyCols))
oRow = oRow + HowManyCols
Next iRow
End With

With NewWks
.Range("c1").EntireColumn.NumberFormat = "mm/dd/yyyy"
.Range("d1").EntireColumn.NumberFormat = "#,##0.00"
.UsedRange.Columns.AutoFit
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Syak wrote:

Current format is:

Jul-06 Aug-2006
East Apples 5,526,415 5,520,890
West Oranges 168,822 4,652
North Peaches 8,555,579 8,886
South Pears 26,515 895,321

What I want is:

East Apples Jul-06 5,526,415
East Apples Aug-06 5,520,890
West Oranges Jul-06 168,822
West Oranges Aug-06 4,652
North Peaches Jul-06 8,555,579
North Peaches Aug-06 8,886
South Pears Jul-06 8,555,579
South Pears Aug-06 895,321

"Dave O" wrote:

Just so we're not talking at cross purposes... can you post some sample
data in "before" and "after" format?



--

Dave Peterson


 
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
Probelm opening an excel 2000 file in excel 2003 Mark Excel Discussion (Misc queries) 1 February 13th 06 07:47 AM
Excel 2003, Convert EXISTING Worksheet Data to XML? [email protected] Excel Discussion (Misc queries) 4 November 16th 05 04:45 AM
Append the data given in diff sheets of an Excel File to one sheet sansk_23 Excel Worksheet Functions 3 May 10th 05 02:00 AM
Hyperlink in Excel 2000 can't open bookmarked Word 2000 file DCheslock Excel Discussion (Misc queries) 1 May 5th 05 10:46 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM


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