Two Loop macro formula help

Amnesiac

Board Regular
Joined
Apr 16, 2009
Messages
144
I have a macro which has two loops looking through a spreadsheet which then list the desired data in another sheet. The first loop searchs through the list for a part name (ie, part1, part2, etc.) I call this the i loop. The second loop, called loop j, then search for all the body subcomponents of the parts. So Part1 may have body1, body2, and body3, then Part2 may contain Body1, Body2, and Part3 may contain multiple bodies as well. On my new sheet I am creating I want to list each part then their subsequent bodies like so...

Row 1. Part1
Row 2. Body1
Row 3. Body2
Row 4. Body3
Row 5. Part2
Row 6. Body1
Row 7. Body2
Row 8. Part3

and so on... I am not sure of the formulas for the loops to display the desired result above. Understand what I am getting at? Here is an example of my loop commands:

For i=1 to NumberofParts

Excel.Cells(i+1,1)=partName

For j=1 to NumberofBodies

Excel.Cells(J+1,1)=namebody
Next 'j
Next 'i
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,202,990
Messages
6,052,961
Members
444,621
Latest member
MIKOLAJ_R

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