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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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