Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Putting column values in multiple rows

Hi, I am using SPSS data and would like to rearrange it in Excel.

The original file contains rows with 64 columns, one row representing 1
record:

Example:
Code mis1 ebus1 cont1 mis2 ebus2 cont2
626 5 6 1 .... (9 values) ... 2 8 7 ....

Now I would like to have, by 9 column values one row, resulting in 7 rows by
record:

Example:
Code mis ebus cont
626 5 6 1 ...
2 8 7 ...
1 1 4 ...
7 7 1 ...
6 6 1 ...
7 7 5 ...
7 7 1 ...

Any help would be appreciated !


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Putting column values in multiple rows

If I were doing this, I'd put that code on each line. It would make filtering
much easier!

This creates a new worksheet and transfers the values over:

Option Explicit
Sub testme()

Dim curWks As Worksheet
Dim newWks As Worksheet
Dim iRow As Long
Dim iCol As Long
Dim oRow As Long


Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

newWks.Range("a1").Resize(1, 4).Value _
= Array("Code", "mis", "ebus", "cont")

oRow = -5
With curWks
For iRow = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
oRow = oRow + 7
For iCol = 2 To 64 Step 9
newWks.Cells(oRow, "A").Resize(7, 1).Value _
= .Cells(iRow, "A").Value

newWks.Cells(oRow + (iCol - 2) / 9, "B").Resize(1, 9).Value _
= .Cells(iRow, "A").Offset(0, (iCol - 2 / 9) - 1) _
.Resize(1, 9).Value
Next iCol
Next iRow
End With

End Sub


If you really only want that code on the first row of the group,

change this:
newWks.Cells(oRow, "A").Resize(7, 1).Value _
= .Cells(iRow, "A").Value

to
newWks.Cells(oRow, "A").Value _
= .Cells(iRow, "A").Value


ChBoodts wrote:

Hi, I am using SPSS data and would like to rearrange it in Excel.

The original file contains rows with 64 columns, one row representing 1
record:

Example:
Code mis1 ebus1 cont1 mis2 ebus2 cont2
626 5 6 1 .... (9 values) ... 2 8 7 ....

Now I would like to have, by 9 column values one row, resulting in 7 rows by
record:

Example:
Code mis ebus cont
626 5 6 1 ...
2 8 7 ...
1 1 4 ...
7 7 1 ...
6 6 1 ...
7 7 5 ...
7 7 1 ...

Any help would be appreciated !


--

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
retrieving multiple corresponding values with variable rows/column soph Excel Worksheet Functions 4 September 15th 09 10:44 AM
How to retrieve multiple values in multiple rows with one criteria bac Excel Discussion (Misc queries) 2 June 15th 07 08:57 PM
Adding multiple values in one column based on multiple values of the same value (text) in another column [email protected] Excel Discussion (Misc queries) 1 May 16th 07 06:02 PM
Formula to compare multiple rows values based on another column? Murph Excel Worksheet Functions 4 February 21st 05 02:44 AM
Problem when trying to convert one column with multiple rows to one row with multiple column marcello Excel Programming 1 February 23rd 04 03:03 AM


All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"