Moving rows to ome row string

2avrham

Board Regular
Joined
May 12, 2014
Messages
104
Office Version
  1. 365
Hi,

There is an option to covert below table layout to one row layout?

Vpo number

<tbody>
</tbody><colgroup><col></colgroup>
WWTaskstatusOCQUDFCommentTypeTPEng_id
Y6192730RS

<tbody>
</tbody><colgroup><col></colgroup>
19hotwip6681sampleVNADNAJDNA11A1
Y6192730RS

<tbody>
</tbody><colgroup><col></colgroup>
19colddone6682sampleASDKAKSFH224CX
Y6192730RS

<tbody>
</tbody><colgroup><col></colgroup>
19edisdone7738sample
Y6192730RS

<tbody>
</tbody><colgroup><col></colgroup>
19ppvdone7739sample

<tbody>
</tbody>

After the change it should look like this and be execute according to "Vpo_number", I have table with many lots numbers and I want that each lot data will be converted to one row only:

Y6192730RS

<tbody>
</tbody><colgroup><col></colgroup>
19hotwip6681sampleVNADNAJDNA11A1

<tbody>
</tbody>
colddone6682sampleASDKAKSFH224CX

<tbody>
</tbody>
edisdone7738sample

<tbody>
</tbody>
ppvdone7739sample

<tbody>
</tbody>

<tbody>
</tbody>

As you can see "Vpo number" & "WW" are the same for all rows therefore I need them only once.

Thanks!!!!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi.
I assumed your headers starting on 'A1'. The output will start on 'M1'
Code:
Sub ReplicateRowsToOneRow()
 Dim LR As Long, k As Long, x As Long, m As Long, t As Long, v As Long
  LR = Cells(Rows.Count, 1).End(3).Row
   For k = 2 To LR
    x = Application.CountIfs(Range(Cells(k, 1), Cells(LR, 1)), Cells(k, 1), Range(Cells(k, 2), Cells(LR, 2)), Cells(k, 2))
    Cells(t + 1, v + 13).Resize(, 10).Value = Cells(k + m, 1).Resize(, 10).Value: v = v + 10
     For m = 1 To x - 1
      Cells(t + 1, v + 13).Resize(, 8).Value = Cells(k + m, 3).Resize(, 8).Value: v = v + 8
     Next m
    k = k + x - 1: t = t + 1: v = 0: m = 0
   Next k
End Sub
 
Upvote 0
Thanks a lot it is exactly what I meant!

One more question how can I edit above VB code for table with more than 10 columns?
 
Upvote 0
Dim LR As Long, k As Long, x As Long, m As Long, t As Long, v As Long
LR = Cells(Rows.Count, 1).End(3).Row
For k = 2 To LR
x = Application.CountIfs(Range(Cells(k, 1), Cells(LR, 1)), Cells(k, 1), Range(Cells(k, 2), Cells(LR, 2)), Cells(k, 2))
Cells(t + 1, v + 13).Resize(, 11).Value = Cells(k + m, 1).Resize(, 11).Value: v = v + 11
For m = 1 To x - 1
Cells(t + 1, v + 13).Resize(, 9).Value = Cells(k + m, 3).Resize(, 9).Value: v = v + 9
Next m
k = k + x - 1: t = t + 1: v = 0: m = 0
Next k
End Sub

for one more cell, right?
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,042
Members
448,940
Latest member
mdusw

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