Data arrangement macro

makinmomb

Active Member
Joined
Dec 23, 2013
Messages
401
I want to re arrange my data as follows , if i do manually it will take long
, cell reference A meaning on sheet 2

[TABLE="width: 192"]
<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]D3[/TD]
[TD="class: xl63, width: 64"]TO[/TD]
[TD="class: xl63, width: 64"]A1[/TD]
[/TR]
[TR]
[TD="class: xl63"]E3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A2[/TD]
[/TR]
[TR]
[TD="class: xl63"]J3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A3[/TD]
[/TR]
[TR]
[TD="class: xl63"]O3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A4[/TD]
[/TR]
[TR]
[TD="class: xl63"]N3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A5[/TD]
[/TR]
[TR]
[TD="class: xl63"]F3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A6[/TD]
[/TR]
[TR]
[TD="class: xl63"]G3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A7[/TD]
[/TR]
[TR]
[TD="class: xl63"]I3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A8[/TD]
[/TR]
[TR]
[TD="class: xl63"]H3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A9[/TD]
[/TR]
[TR]
[TD="class: xl63"]B3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A10[/TD]
[/TR]
[TR]
[TD="class: xl63"]K3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A11[/TD]
[/TR]
[TR]
[TD="class: xl63"]M3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A12[/TD]
[/TR]
[TR]
[TD="class: xl66"]C3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A13[/TD]
[/TR]
[TR]
[TD="class: xl64"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl63"][/TD]
[/TR]
[TR]
[TD="class: xl66"]W3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A14[/TD]
[/TR]
[TR]
[TD="class: xl66"]U3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A15[/TD]
[/TR]
[TR]
[TD="class: xl66"]V3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A16[/TD]
[/TR]
[TR]
[TD="class: xl66"]S3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A17[/TD]
[/TR]
[TR]
[TD="class: xl66"]T3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A18[/TD]
[/TR]
[TR]
[TD="class: xl66"]X3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A19[/TD]
[/TR]
[TR]
[TD="class: xl66"]AA3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A20[/TD]
[/TR]
[TR]
[TD="class: xl63"]Y3[/TD]
[TD="class: xl63"]TO[/TD]
[TD="class: xl63"]A21[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Here's a way without VBA.

Enter the Sheet1 cell refs in column B of Sheet2
Enter in A1 of Sheet2 and fill down : =INDIRECT("Sheet1!" & B1)
Convert Sheet2 column A to value
Delete Sheet2 column B
 
Upvote 0
I have to data sheets of like 100 rows thus need this macro badly before this work eats away my day doing it the painful manner
 
Upvote 0
Assuming your data starts on Row 3 (as your posted example suggests), and assuming you want the output to go to Sheet2, give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub ReorderTransposeColumns()
  Dim LastRow As Long, Rng As Range
  LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious, , , False).Row
  Sheets("Sheet2").Range("A1").Resize(21, LastRow - 2) = Application.Transpose(Application.Index(Cells, Evaluate("ROW(3:" & LastRow & ")"), Split("4 5 10 15 14 6 7 9 8 2 11 13 3 23 21 22 19 20 24 27 25")))
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Rick thank you , i dont need even the extra sheets , i hope the macro will work too for say 10 trucks , thus were data for 3 trucks
 
Upvote 0
Rick can you please edit the macro to correct this output , at where it picks 3195000 there needs to be
1500 prior that being the quantity of the value , like it did 500 followed by 1185000

[TABLE="width: 145"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]911000[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]3195000[/TD]
[/TR]
[TR]
[TD="align: right"]500[/TD]
[/TR]
[TR]
[TD="align: right"]1185000[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
I must say its rick who introduced me to macros , i recall he even gave
me the the keys to get to the module and run a macro , since then i have
saved tons of hours and courtesy thx Rick to have changed my style of
how i use Excel , i am sure to have saved tons of hours and rocking to
better jobs due to the speed macros give
 
Upvote 0
Oh yeah it extracts records endlessly , i tried to append data at below the file and does the needful , thank you rick again for taking care of that too
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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
Back
Top