Hi there,
I have some data which is in the below format. I'd like to manipulate this so it looks like the second table. However I'm having some trouble with my loop where I can only run it for client 1, and can't figure out how to add client 2 and 3 to the column K with the respective quantities, price and product.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]Product[/TD]
[TD="align: center"]Quantity[/TD]
[TD="align: center"]Price[/TD]
[TD="align: center"]Client 1[/TD]
[TD="align: center"]Client 2[/TD]
[TD="align: center"]Client 3[/TD]
[/TR]
[TR]
[TD="align: center"]Bread[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]$1.00[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]Milk[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]$0.80[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]4[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Quantity[/TD]
[TD]Price[/TD]
[TD]Client[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]4[/TD]
[TD]1.00[/TD]
[TD]Client 1[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]3[/TD]
[TD]1.00[/TD]
[TD]Client 2[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]3[/TD]
[TD]1.00[/TD]
[TD]Client 3[/TD]
[/TR]
[TR]
[TD]Milk[/TD]
[TD]8[/TD]
[TD]0.80[/TD]
[TD]Client 1[/TD]
[/TR]
[TR]
[TD]Milk[/TD]
[TD]4[/TD]
[TD]0.80[/TD]
[TD]Client 3[/TD]
[/TR]
</tbody>[/TABLE]
Any ideas of where I'm going wrong?
Ta!
I have some data which is in the below format. I'd like to manipulate this so it looks like the second table. However I'm having some trouble with my loop where I can only run it for client 1, and can't figure out how to add client 2 and 3 to the column K with the respective quantities, price and product.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]Product[/TD]
[TD="align: center"]Quantity[/TD]
[TD="align: center"]Price[/TD]
[TD="align: center"]Client 1[/TD]
[TD="align: center"]Client 2[/TD]
[TD="align: center"]Client 3[/TD]
[/TR]
[TR]
[TD="align: center"]Bread[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]$1.00[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]Milk[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]$0.80[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]4[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Quantity[/TD]
[TD]Price[/TD]
[TD]Client[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]4[/TD]
[TD]1.00[/TD]
[TD]Client 1[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]3[/TD]
[TD]1.00[/TD]
[TD]Client 2[/TD]
[/TR]
[TR]
[TD]Bread[/TD]
[TD]3[/TD]
[TD]1.00[/TD]
[TD]Client 3[/TD]
[/TR]
[TR]
[TD]Milk[/TD]
[TD]8[/TD]
[TD]0.80[/TD]
[TD]Client 1[/TD]
[/TR]
[TR]
[TD]Milk[/TD]
[TD]4[/TD]
[TD]0.80[/TD]
[TD]Client 3[/TD]
[/TR]
</tbody>[/TABLE]
Code:
Dim row As Integer
row = 2
Do While .Range("A" & row) <> ""
If .Range("B" & row) > 0 Then
.Range("H" & row) = Range("A" & row)
.Range("I" & row) = Range("B" & row)
.Range("J" & row) = Range("C" & row)
.Range("D" & row) = Range("K" & row)
'doesn't continue to add these clients
.Range("E" & row) = Range("K" & row)
.Range("F" & row) = Range("K" & row)
'etc....
End If
row = row + 1
Loop
Any ideas of where I'm going wrong?
Ta!