Manipulating data

mpd

New Member
Joined
Sep 21, 2006
Messages
2
I have a set of 2001 data points in 3 columns:

1 2 3
4 5 6
7 8 9
10 11 ..

and I want to convert it to 9 columns:

1 2 3 4 5 6 7 8 9
10 11 ..

Is there any way I can do this?

Big thanks to anyone who can help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
HI

Do you want a formula solution, or a macro solution?


Tony
 

mpd

New Member
Joined
Sep 21, 2006
Messages
2
A formula solution would be great since I'm not that familiar with macros. But I'm open to whatever gets the job done best since I have 27 files to do this to.
 

Artemus

Board Regular
Joined
Dec 30, 2004
Messages
92
Try the following. You should first select the top left cell in the range you want to adjust and then run the macro. This is potentially destructive, so be sure to have a backup copy of your data.

Sub ThreeToNine()
Do
ActiveCell.Offset(0, 3).Formula = ActiveCell.Offset(1, 0).Formula
ActiveCell.Offset(0, 4).Formula = ActiveCell.Offset(1, 1).Formula
ActiveCell.Offset(0, 5).Formula = ActiveCell.Offset(2, 2).Formula
ActiveCell.Offset(0, 6).Formula = ActiveCell.Offset(1, 2).Formula
ActiveCell.Offset(0, 7).Formula = ActiveCell.Offset(2, 0).Formula
ActiveCell.Offset(0, 8).Formula = ActiveCell.Offset(2, 1).Formula
ActiveCell.Offset(1, 0).Select
Selection.EntireRow.Delete
Selection.EntireRow.Delete
If Len(ActiveCell.Formula) = 0 Then Exit Do
Loop
End Sub
 

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029

ADVERTISEMENT

See
Managing data that include logical blocks
http://www.tushar-mehta.com/excel/tips/data_in_blocks/

The explanation might be a little too concise but the methodology is good.

I have a set of 2001 data points in 3 columns:

1 2 3
4 5 6
7 8 9
10 11 ..

and I want to convert it to 9 columns:

1 2 3 4 5 6 7 8 9
10 11 ..

Is there any way I can do this?

Big thanks to anyone who can help.
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Assuming that your data is in columns A:C, starting in A1 then enter the formula

=OFFSET($A$1,INT(COLUMN()/3)-2+(ROW()-1)*3,MOD(COLUMN(),3))

in F1, copy across to N1, then copy F1:N1 down as required.


Tony
 

agihcam

Well-known Member
Joined
Jan 16, 2006
Messages
1,624
also try;
Code:
Sub sample2()
Dim i, n As Long
Application.ScreenUpdating = False
n = 4
For i = 1 To Range("a" & Rows.Count).End(xlUp).Row
Cells(i, "d").Resize(, 3).Value = Cells(i + 1, "a").Resize(, 3).Value
Cells(i, "g").Resize(, 3).Value = Cells(i + 2, "a").Resize(, 3).Value
Cells(i + 1, "a").Resize(3, 3).Value = Cells(n, "a").Resize(3, 3).Value
n = n + 3
Next
Application.ScreenUpdating = True
End Sub
 

Forum statistics

Threads
1,136,266
Messages
5,674,727
Members
419,523
Latest member
Urnovio

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top