Hello All,
I have never done programming in VB so this is fairly new, had done some PB programming more than 20 years ago but can't remember anything . I exhausted in-built sort option Excel provides for what I want to achieve.
I need some help in restructuring data that I download frequently from a website for products and upload them after updating prices and some other information. The issue I run into is that some of the parent and child records are scattered and I often have to manually move the rows to make updates resulting in hours of lost time. Since we download and upload it frequently I think it makes sense to write a macro for restructuring the rows.
Here's an example of the data that we download:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Short Desc[/TD]
[TD]Parent[/TD]
[TD]Reg Price[/TD]
[TD]Sale Price[/TD]
[TD]lots of other cols.[/TD]
[/TR]
[TR]
[TD]660[/TD]
[TD]Product 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]661[/TD]
[TD]Product 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]662[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]45[/TD]
[TD]40[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]663[/TD]
[TD][/TD]
[TD]660[/TD]
[TD]50[/TD]
[TD]44[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]664[/TD]
[TD][/TD]
[TD]660[/TD]
[TD]44[/TD]
[TD]23[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]665[/TD]
[TD]Product 3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]666[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]55[/TD]
[TD]55[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]667[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]12[/TD]
[TD]11[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]668[/TD]
[TD][/TD]
[TD]665[/TD]
[TD]10[/TD]
[TD]9[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]...[/TD]
[TD][/TD]
[TD]...[/TD]
[TD]...[/TD]
[TD]...[/TD]
[TD]...[/TD]
[/TR]
</tbody>[/TABLE]
ID is just a running number when each new product is created in the system. Parent col is empty when it's a parent record, if it has ID in it then it's a child product and it's linked to the Parent product. In this case, I'd like the code to move rows 4 and 5 from above table below row 1, example below:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Short Desc[/TD]
[TD]Parent[/TD]
[TD]Reg Price[/TD]
[TD]Sale Price[/TD]
[/TR]
[TR]
[TD]660[/TD]
[TD]Product 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]663[/TD]
[TD][/TD]
[TD]660[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]664[/TD]
[TD][/TD]
[TD]660[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]661[/TD]
[TD]Product 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]662[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]666[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]667[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]665[/TD]
[TD]Product 3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I'm using Office 2016 version.
Thanks in advance!
I have never done programming in VB so this is fairly new, had done some PB programming more than 20 years ago but can't remember anything . I exhausted in-built sort option Excel provides for what I want to achieve.
I need some help in restructuring data that I download frequently from a website for products and upload them after updating prices and some other information. The issue I run into is that some of the parent and child records are scattered and I often have to manually move the rows to make updates resulting in hours of lost time. Since we download and upload it frequently I think it makes sense to write a macro for restructuring the rows.
Here's an example of the data that we download:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Short Desc[/TD]
[TD]Parent[/TD]
[TD]Reg Price[/TD]
[TD]Sale Price[/TD]
[TD]lots of other cols.[/TD]
[/TR]
[TR]
[TD]660[/TD]
[TD]Product 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]661[/TD]
[TD]Product 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]662[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]45[/TD]
[TD]40[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]663[/TD]
[TD][/TD]
[TD]660[/TD]
[TD]50[/TD]
[TD]44[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]664[/TD]
[TD][/TD]
[TD]660[/TD]
[TD]44[/TD]
[TD]23[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]665[/TD]
[TD]Product 3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]666[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]55[/TD]
[TD]55[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]667[/TD]
[TD][/TD]
[TD]661[/TD]
[TD]12[/TD]
[TD]11[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]668[/TD]
[TD][/TD]
[TD]665[/TD]
[TD]10[/TD]
[TD]9[/TD]
[TD]...[/TD]
[/TR]
[TR]
[TD]...[/TD]
[TD][/TD]
[TD]...[/TD]
[TD]...[/TD]
[TD]...[/TD]
[TD]...[/TD]
[/TR]
</tbody>[/TABLE]
ID is just a running number when each new product is created in the system. Parent col is empty when it's a parent record, if it has ID in it then it's a child product and it's linked to the Parent product. In this case, I'd like the code to move rows 4 and 5 from above table below row 1, example below:
[TABLE="width: 500"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Short Desc[/TD]
[TD]Parent[/TD]
[TD]Reg Price[/TD]
[TD]Sale Price[/TD]
[/TR]
[TR]
[TD]660[/TD]
[TD]Product 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]663[/TD]
[TD][/TD]
[TD]660[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]664[/TD]
[TD][/TD]
[TD]660[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]661[/TD]
[TD]Product 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]662[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]666[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]667[/TD]
[TD][/TD]
[TD]661[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]665[/TD]
[TD]Product 3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I'm using Office 2016 version.
Thanks in advance!