Good day,
I would like some help to modify a macro in order for me to get the data set as I want it.
the data set currently looks like
<COLGROUP><COL style="WIDTH: 16pt; mso-width-source: userset; mso-width-alt: 768" width=21><COL style="WIDTH: 165pt; mso-width-source: userset; mso-width-alt: 8045" width=220><COL style="WIDTH: 48pt" span=4 width=64><COL style="WIDTH: 74pt; mso-width-source: userset; mso-width-alt: 3584" width=98><COL style="WIDTH: 48pt" width=64><COL style="WIDTH: 58pt; mso-width-source: userset; mso-width-alt: 2816" width=77><COL style="WIDTH: 257pt; mso-width-source: userset; mso-width-alt: 12507" width=342><COL style="WIDTH: 83pt; mso-width-source: userset; mso-width-alt: 4059" width=111><COL style="WIDTH: 89pt; mso-width-source: userset; mso-width-alt: 4352" width=119><COL style="WIDTH: 48pt" span=17 width=64><TBODY>
</TBODY>
I would like to have it in the following format
<COLGROUP><COL style="WIDTH: 16pt; mso-width-source: userset; mso-width-alt: 768" width=21><COL style="WIDTH: 76pt; mso-width-source: userset; mso-width-alt: 3693" width=101><COL style="WIDTH: 48pt" width=64><COL style="WIDTH: 77pt; mso-width-source: userset; mso-width-alt: 3766" width=103><COL style="WIDTH: 98pt; mso-width-source: userset; mso-width-alt: 4754" width=130><COL style="WIDTH: 65pt; mso-width-source: userset; mso-width-alt: 3181" width=87><COL style="WIDTH: 189pt; mso-width-source: userset; mso-width-alt: 9216" width=252><COL style="WIDTH: 48pt" width=64><TBODY>
</TBODY>
The macro that I used before is presented below but is not working with the current structure of the report. I would be very thankful if someone could modify it to work properly.
Sub Me3n()
Dim Rng As Range
Dim Dn As Range
Dim Ac As Integer
Dim Num As String
Dim c As Long
Set Rng = Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 29)
For Each Dn In Rng
If Not IsEmpty(Dn.Value) Then
If Split(Dn, " ")(0) = "Purchasing" Then
Num = Split(Dn, " ")(2)
Else
c = c + 1
For Ac = 1 To 28
If Num = "" Then
ray(c, 1) = "Purchasing Document"
ray(c, Ac + 1) = Dn(, Ac)
Else
ray(c, 1) = Num
ray(c, Ac + 1) = Dn(, Ac)
End If
Next Ac
End If
End If
Next Dn
Sheets("Sheet2").Range("A1").Resize(c, 29) = ray
End Sub
Best regards,
Akakaboto
I would like some help to modify a macro in order for me to get the data set as I want it.
the data set currently looks like
A | B | C | D | E | F | G | H | |||||||||||||||||||||
1 | Item | Purchasing Doc. Type | Purch. Doc. Category | Purchasing Group | PO history/release documentation | Document Date | Vendor/supplying plant | Material | Short Text | Validity Per. Start | Validity Period End | Material Group | Deletion Indicator | Item Category | Acct Assignment Cat. | Plant | Storage Location | Order Quantity | Order Unit | Quantity in SKU | Stockkeeping unit | Net price | Currency | Price Unit | Target Val. (Header) | Target Quantity | Open Target Quantity | No. of Positions |
2 | 19542 | |||||||||||||||||||||||||||
3 | Purchasing Document 200610026 | 3 | ||||||||||||||||||||||||||
4 | 10 | YF4W | K | A09 | 2012-12-20 | A | 4000012991 | XX | 2013-01-01 | 2013-12-31 | 96201000 | V | P145 | 0,000 | EA | 0,000 | KG | 3300,00 | USD | 1 | 0,00 | 0,000 | 0,000 | 1 | ||||
5 | 20 | YF4W | K | A09 | 2012-12-20 | A | 4000012992 | XY | 2013-01-01 | 2013-12-31 | 96201000 | V | P145 | 0,000 | EA | 0,000 | KG | 3200,00 | USD | 1 | 0,00 | 0,000 | 0,000 | 1 | ||||
6 | 30 | YF4W | K | A09 | 2012-12-20 | A | 4000012993 | XZ | 2013-01-01 | 2013-12-31 | 96201000 | V | P145 | 0,000 | EA | 0,000 | KG | 3200,00 | USD | 1 | 0,00 | 0,000 | 0,000 | 1 | ||||
7 | Purchasing Document 200610045 | 2 | ||||||||||||||||||||||||||
8 | 10 | YF4W | K | A03 | 2012-10-31 | 100072 DHL Freight (Sweden) AB | 4000000553 | SE Dalsland - SE Arvika | 2011-11-21 | 2013-12-31 | 96406000 | V | P145 | 0,000 | KG | 0,000 | KG | 53,30 | SEK | 100 | 0,00 | 0,000 | 0,000 | 1 | ||||
9 | 20 | YF4W | K | A03 | @0N\QPO history/release documentati@ | 2012-10-31 | 100072 DHL Freight (Sweden) AB | 4000000554 | SE Värmland - SE Arvika | 2011-11-21 | 2013-12-31 | 96406000 | V | P145 | 0,000 | KG | 0,000 | KG | 58,00 | SEK | 100 | 0,00 | 0,000 | 0,000 | 1 | |||
10 | Purchasing Document 200610107 | 3 | ||||||||||||||||||||||||||
11 | 10 | YF4W | K | A16 | @0N\QPO history/release documentati@ | 2012-12-20 | 109852 Hoyer Svenska AB | 4000008287 | SE Helsingborg-SE Göteborg,Spolarvätska | 2013-01-01 | 2013-12-31 | 96403000 | V | P145 | 0,000 | EA | 0,000 | KG | 15391,00 | SEK | 1 | 0,00 | 0,000 | 0,000 | 1 | |||
12 | 20 | YF4W | K | A16 | 2012-12-20 | 109852 Hoyer Svenska AB | 4090000111 | Loading/discharge 3hrs incl, cost/hour | 2013-01-01 | 2013-12-31 | 96403000 | V | P145 | 0,000 | EA | 0,000 | EA | 535,00 | SEK | 1 | 0,00 | 0,000 | 0,000 | 1 | ||||
13 | 30 | YF4W | K | A16 | 2012-12-20 | 109852 Hoyer Svenska AB | 4690000024 | Cont.rent incl arrival+1day, cost/day | 2013-01-01 | 2013-12-31 | 96403000 | V | P145 | 0,000 | EA | 0,000 | EA | 350,00 | SEK | 1 | 0,00 | 0,000 | 0,000 | 1 |
<COLGROUP><COL style="WIDTH: 16pt; mso-width-source: userset; mso-width-alt: 768" width=21><COL style="WIDTH: 165pt; mso-width-source: userset; mso-width-alt: 8045" width=220><COL style="WIDTH: 48pt" span=4 width=64><COL style="WIDTH: 74pt; mso-width-source: userset; mso-width-alt: 3584" width=98><COL style="WIDTH: 48pt" width=64><COL style="WIDTH: 58pt; mso-width-source: userset; mso-width-alt: 2816" width=77><COL style="WIDTH: 257pt; mso-width-source: userset; mso-width-alt: 12507" width=342><COL style="WIDTH: 83pt; mso-width-source: userset; mso-width-alt: 4059" width=111><COL style="WIDTH: 89pt; mso-width-source: userset; mso-width-alt: 4352" width=119><COL style="WIDTH: 48pt" span=17 width=64><TBODY>
</TBODY>
I would like to have it in the following format
A | B | C | D | E | F | G....... | |
1 | Purchase order | Item | Purchasing Doc. Type | Purch. Doc. Category | Purchasing Group | PO history/release documentation | etc. |
2 | 200610026 | 10 | YF4W | K | A09 | ||
3 | 200610026 | 20 | YF4W | K | A09 | ||
4 | 200610026 | 30 | YF4W | K | A09 | ||
5 | 200610045 | 10 | YF4W | K | A03 | ||
6 | 200610045 | 20 | YF4W | K | A03 | @0N\QPO history/release documentati@ | |
7 | 200610107 | 10 | YF4W | K | A16 | @0N\QPO history/release documentati@ | |
8 | 200610107 | 20 | YF4W | K | A16 | ||
9 | 200610107 | 30 | YF4W | K | A16 | ||
10 | ......... |
<COLGROUP><COL style="WIDTH: 16pt; mso-width-source: userset; mso-width-alt: 768" width=21><COL style="WIDTH: 76pt; mso-width-source: userset; mso-width-alt: 3693" width=101><COL style="WIDTH: 48pt" width=64><COL style="WIDTH: 77pt; mso-width-source: userset; mso-width-alt: 3766" width=103><COL style="WIDTH: 98pt; mso-width-source: userset; mso-width-alt: 4754" width=130><COL style="WIDTH: 65pt; mso-width-source: userset; mso-width-alt: 3181" width=87><COL style="WIDTH: 189pt; mso-width-source: userset; mso-width-alt: 9216" width=252><COL style="WIDTH: 48pt" width=64><TBODY>
</TBODY>
The macro that I used before is presented below but is not working with the current structure of the report. I would be very thankful if someone could modify it to work properly.
Sub Me3n()
Dim Rng As Range
Dim Dn As Range
Dim Ac As Integer
Dim Num As String
Dim c As Long
Set Rng = Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 29)
For Each Dn In Rng
If Not IsEmpty(Dn.Value) Then
If Split(Dn, " ")(0) = "Purchasing" Then
Num = Split(Dn, " ")(2)
Else
c = c + 1
For Ac = 1 To 28
If Num = "" Then
ray(c, 1) = "Purchasing Document"
ray(c, Ac + 1) = Dn(, Ac)
Else
ray(c, 1) = Num
ray(c, Ac + 1) = Dn(, Ac)
End If
Next Ac
End If
End If
Next Dn
Sheets("Sheet2").Range("A1").Resize(c, 29) = ray
End Sub
Best regards,
Akakaboto