Excel transpose

Hansraj

New Member
Joined
Jan 23, 2018
Messages
2
Hi Sir
I have mentioned below table:
[TABLE="width: 325"]
<tbody>[TR]
[TD]ORDER_NO
[/TD]
[TD]Reason For Rejection
[/TD]
[/TR]
[TR]
[TD]4532599
[/TD]
[TD]Allocation Stock
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Mismatch Packing
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Surplus
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD](blank)
[/TD]
[/TR]
[TR]
[TD]4535662
[/TD]
[TD](blank)
[/TD]
[/TR]
[TR]
[TD]4535724
[/TD]
[TD]Unavailability of Stock
[/TD]
[/TR]
[TR]
[TD]4535729
[/TD]
[TD]Allocation Stock
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Unavailability of Stock
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD](blank)
[/TD]
[/TR]
[TR]
[TD]4535738
[/TD]
[TD]Allocation Stock
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]Mismatch Packing
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD](blank)
[/TD]
[/TR]
</tbody>[/TABLE]

And I want result as mention below:

[TABLE="width: 584"]
<tbody>[TR]
[TD][TABLE="width: 523"]
<tbody>[TR]
[TD]ORDER_NO
[/TD]
[TD]Reason For Rejection
[/TD]
[TD]Reason For Rejection
[/TD]
[TD]Reason For Rejection
[/TD]
[TD]Reason For Rejection
[/TD]
[/TR]
[TR]
[TD]4532599
[/TD]
[TD]Allocation Stock
[/TD]
[TD]Mismatch Packing
[/TD]
[TD]Surplus
[/TD]
[TD](blank)
[/TD]
[/TR]
[TR]
[TD]4535662
[/TD]
[TD](blank)
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]4535724
[/TD]
[TD]Unavailability of Stock
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]4535729
[/TD]
[TD]Allocation Stock
[/TD]
[TD]Unavailability of Stock
[/TD]
[TD](blank)
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]4535738
[/TD]
[TD]Allocation Stock
[/TD]
[TD]Mismatch Packing
[/TD]
[TD](blank)
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]

Thanks
Hansraj
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this

Code:
Sub TransTable()
Lastrow = Worksheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row
j = ""
k = 0
For i = 2 To Lastrow
If Worksheets("Sheet1").Cells(i, 1) = "" Then
  l = j: m = m + 1
Else
  l = Worksheets("Sheet1").Cells(i, 1)
  m = 2
  k = k + 1
  Worksheets("Sheet2").Cells(k, 1) = l
End If
j = l
Worksheets("Sheet2").Cells(k, m) = Cells(i, 2)
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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