Excel VBA - Rearranging The Data Into A Report Format

SpicyVNoodle

New Member
Joined
May 6, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello, I'm new to the world of VBA and I need some help for coding.

I need the following set of data to be put into a report format as below;

Data Set
enter image description here



Report Format
enter image description here



What the report should look like;
  1. Count the number of Orders and put the number in column A. For example there are total 3 orders: OR-01, AA_01, and BB~02. Then column A shows 1, 2 or 3)
  2. Per each of Order, put the Item name, Product number, Color, Type, Unit (always cm) then put the Size based on the number of Quantity. For example the first item has 4 Quantity for 50 Size, then put 50 50 50 50. Once it goes over 5, put the data in the next section.
  3. If the quantity is more than 10, put Size x Quality in a merged cell. For example if the size is 23 and quality is 15, put it as 23 x 15 for column G and H then the next item is put in the column I
  4. Count of each of the Item and Color
  5. Total of the each of Item and Color
Any part of coding for each of the section would be much appreciated. Or any ideas to how to approach to code this format would be also very appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I was thinking that it may be easy to use loop to grab data in each roll instead of checking the different number of Quantity.

I found this code on the web that can copy additional rows for the number of Quantity.

Sub CopyData()
Dim xRow As Long
Dim VInSertNum As Variant
xRow = 1

Do While (Cells(xRow, "A") <> "")
VInSertNum = Cells(xRow, "N")
If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then
Range(Cells(xRow, "A"), Cells(xRow, "N")).Copy
Range(Cells(xRow + 1, "A"), Cells(xRow + VInSertNum - 1, "N")).Select
Selection.Insert Shift:=xlDown
xRow = xRow + VInSertNum - 1
End If
xRow = xRow + 1
Loop
End Sub

I still don't know how to populate the Size data for only 5 times from Column G to Column K then continue inputting the Size data in the next row without inputting Name, Product No, Color, Type, Unit data.
 
Upvote 0
I was thinking that it may be easy to use loop to grab data in each roll instead of checking the different number of Quantity.

I found this code on the web that can copy additional rows for the number of Quantity.

Sub CopyData()
Dim xRow As Long
Dim VInSertNum As Variant
xRow = 1

Do While (Cells(xRow, "A") <> "")
VInSertNum = Cells(xRow, "N")
If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then
Range(Cells(xRow, "A"), Cells(xRow, "N")).Copy
Range(Cells(xRow + 1, "A"), Cells(xRow + VInSertNum - 1, "N")).Select
Selection.Insert Shift:=xlDown
xRow = xRow + VInSertNum - 1
End If
xRow = xRow + 1
Loop
End Sub

I still don't know how to populate the Size data for only 5 times from Column G to Column K then continue inputting the Size data in the next row without inputting Name, Product No, Color, Type, Unit data.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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