Domanda

I need help creating a macro that will perform the following function, or something similar (I am not sure whether it is even possible to create such a macro) :

I have 60,000 + rows of data with two columns, ASSEMBLIES and COMPONENTS. An Assembly has multiple components ex:

ASSEMBLY/COMPS IMAGE

However, an Assembly can also be a component.

I need to make a tree of the relationships between assemblies and components, so basically find the highest level and then all its children assemblies and all the children of those children.

Please do let me know if there is a way I can do this as it would make things much easier!

È stato utile?

Soluzione

OK, for the 2nd approach I think I would set up the following: Sheet 1 - your existing data table with 60,000 rows

Sheet 2 - "Goes into" analysis, with a specific part number in cell A1 (or wherever you want it), and cell A1 selected

A "Goes into" macro that does the following:

Starts in the current cell , increments the row number and sets an indent level of 1

Gets a list of all the matches in the data table for assemblies that the selected component goes into (see http://office.microsoft.com/en-us/excel-help/how-to-look-up-a-value-in-a-list-and-return-multiple-corresponding-values-HA001226038.aspx#_Toc273640147)

Decrements the indent level and Ends if there are no entries in the resulting list, otherwise for each entry in the list, it puts the matching assembly number into the current cell (using the indent level to add leading spaces, or format as needed), increments the row number, increments the indent level and calls the "Goes into" macro recursively for the assembly number

This macro will basically produce an indented list of higher level assemblies for the part number placed in cell A1.

Sheet 3 - Then add another sheet for a "Contains" analysis and set it up the same way - or if you prefer, it could be on Sheet 2 in a different column. This second analysis is the same as the 1st, except that you start with list of components going into the assembly instead of a list of assemblies that the component goes into.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top