Hi, I need help with macro to Automate the following.
Column A-D is static data.
Column E onwards lists part numbers as comma separated values for different product groups (the amount of columns and rows can vary and so can product group names)
I need to achieve the following.
Loop/iterate through the columns E onwards
If there is data in the column then copy A-D and focused column to a new worksheet.
Add a column with a formula to count the number of comma delimited products in the column (=IF(P2="","0",(LEN(TRIM(P2))-LEN(SUBSTITUTE(TRIM(P2),",",""))+"1")))
Add another column which will be D2/Result above
Paste the values
Separate the comma delimited values into new columns.
Example Raw Data
Result
Worksheet1 - Raw Data
Worksheet2 - Switches
Worksheet3 - Sensors
Worksheet4 - Brake Components
Column A-D is static data.
Column E onwards lists part numbers as comma separated values for different product groups (the amount of columns and rows can vary and so can product group names)
I need to achieve the following.
Loop/iterate through the columns E onwards
If there is data in the column then copy A-D and focused column to a new worksheet.
Add a column with a formula to count the number of comma delimited products in the column (=IF(P2="","0",(LEN(TRIM(P2))-LEN(SUBSTITUTE(TRIM(P2),",",""))+"1")))
Add another column which will be D2/Result above
Paste the values
Separate the comma delimited values into new columns.
Example Raw Data
ID (A) | Make (B) | Model (C) | VIO (D) | Switches (E) | Sensors (F) | Brake Components (G) | |
1 | Ford | Fiesta | 12548 | 85421, 44457, 74544 | 99875, 45125 | ||
2 | Vauxhall | Astra | 89712 | 89842 | 98751, 54547, 54548 |
Result
Worksheet1 - Raw Data
Worksheet2 - Switches
ID | Make | Model | VIO | VIO Divided by Count | Count of product | Switches | ||
1 | Ford | Fiesta | 12548 | =12548/3 | 3 | 85421 | 44457 | 74544 |
2 | Vauxhall | Astra | 89712 | =89712/1 | 1 | 89842 |
Worksheet3 - Sensors
ID | Make | Model | VIO | VIO Divided by Count | Count of Product | Sensors | |
1 | Ford | Fiesta | 12548 | =12548/2 | 2 | 99875 | 45125 |
2 | Vauxhall | Astra | 89712 | (=IFERROR(D3/E3,0)) | 0 |
Worksheet4 - Brake Components
ID | Make | Model | VIO | VIO Divided by Count | Count of Product | Brake Components | ||
1 | Ford | Fiesta | 12548 | =12548/0 | 0 | |||
2 | Vauxhall | Astra | 89712 | =89712/3 | 3 | 98751 | 54547 | 54548 |