Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default transposing data question

I've search for a week now and can't seem to find an answer.

I have a spreadsheet that contains about 150 columns with row 1 being an
account number and rows 2..n contain products purchased. Example:
10 20
apples cans
oranges boxes
grapes

Some clients may have only 1 product while another client may have 300.

How can I transpose the data into rows and maintain the account number with
the item? Example:
10 apples
10 oranges
10 grapes
20 cans
20 boxes

Any help would be appreciated.

Thanks,
Allan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,104
Default transposing data question

This seems to work

Sub makelist()
Worksheets("Sheet1").Activate
LastAccount = Range("A1", Range("A1").End(xlToRight)).Count
RowCount = 1
For j = 1 To LastAccount
ThisAccount = Cells(1, j)
MyRow = 2
Do
If Cells(MyRow, j) = "" Then Exit Do
' MsgBox Cells(MyRow, j)
Worksheets("Sheet2").Cells(RowCount, 1) = ThisAccount
Worksheets("Sheet2").Cells(RowCount, 2) = Cells(MyRow, j)
MyRow = MyRow + 1
RowCount = RowCount + 1
Loop
Next j
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Allan" wrote in message
...
I've search for a week now and can't seem to find an answer.

I have a spreadsheet that contains about 150 columns with row 1 being an
account number and rows 2..n contain products purchased. Example:
10 20
apples cans
oranges boxes
grapes

Some clients may have only 1 product while another client may have 300.

How can I transpose the data into rows and maintain the account number
with
the item? Example:
10 apples
10 oranges
10 grapes
20 cans
20 boxes

Any help would be appreciated.

Thanks,
Allan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default transposing data question


Try code like

Sub AA()
Dim RR As Range
Dim RC As Range
Dim Dest As Range
Dim H As String

' Set RR to the first cell of original data
Set RR = Worksheets("Sheet1").Range("A1")
' Set Dest to the first cell of the summarized data
Set Dest = Worksheets("Sheet2").Range("A1")

Do Until RR.Value = vbNullString
H = RR.Value
Set RC = RR(2, 1)
Do Until RC.Value = vbNullString
Dest(1, 1).Value = H
Dest(1, 2).Value = RC.Value
Set RC = RC(2, 1)
Set Dest = Dest(2, 1)
Loop
Set RR = RR(1, 2)
Loop
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Fri, 27 Mar 2009 06:25:03 -0700, Allan
wrote:

I've search for a week now and can't seem to find an answer.

I have a spreadsheet that contains about 150 columns with row 1 being an
account number and rows 2..n contain products purchased. Example:
10 20
apples cans
oranges boxes
grapes

Some clients may have only 1 product while another client may have 300.

How can I transpose the data into rows and maintain the account number with
the item? Example:
10 apples
10 oranges
10 grapes
20 cans
20 boxes

Any help would be appreciated.

Thanks,
Allan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default transposing data question

Bernard/Chip;

Thank you both so much! I tried both solutions and both worked perfectly!

Thanks again!
Allan

"Allan" wrote:

I've search for a week now and can't seem to find an answer.

I have a spreadsheet that contains about 150 columns with row 1 being an
account number and rows 2..n contain products purchased. Example:
10 20
apples cans
oranges boxes
grapes

Some clients may have only 1 product while another client may have 300.

How can I transpose the data into rows and maintain the account number with
the item? Example:
10 apples
10 oranges
10 grapes
20 cans
20 boxes

Any help would be appreciated.

Thanks,
Allan

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
transposing data Sriram Excel Discussion (Misc queries) 3 October 25th 09 03:15 PM
Transposing Question Coenraad Excel Discussion (Misc queries) 3 May 26th 09 06:35 PM
Transposing data? Sarah (OGI) Excel Worksheet Functions 3 September 7th 07 10:36 PM
transposing vertical data to horizontal with varying amount of data Ghosty Excel Discussion (Misc queries) 5 August 1st 06 05:20 AM
transposing question... cherrynich Excel Worksheet Functions 2 April 24th 06 03:49 PM


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