Using Microsoft Query I have retrieved a list from our SQL database that gives all of the Parent Parts Number in col. A and in col. B it lists all of the Minor Part Numbers that go into making up the Parent Part. I tried using the Index/Match command to retrieve a all of the minor parts but that command only returns the first value it finds then stops. What I want to do is in, say, Sheet 2 I want to type in a Parent Part Number and have Excel return all of the Minor Part Numbers. Does anyone have any suggestions on how I can do this?
There could be as few as 3 Minor Parts and as many as 10.
Thanks in advance for any help that you can provide.
Stats
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Index/Match (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Index/Match (2000)
- This topic has 16 replies, 6 voices, and was last updated 22 years, 9 months ago.
AuthorTopicWSStats
AskWoody LoungerAugust 20, 2002 at 4:59 pm #375268Viewing 2 reply threadsAuthorReplies-
H. Legare Coleman
AskWoody Plus -
WSStats
AskWoody LoungerAugust 21, 2002 at 11:52 am #610330Good Morning Legare,
No, all of the minor parts appear in their own cell. MS Query returns them roughly as follows:
A B
1 FGABC1.0 BTTOR1.0
2 FGABC1.0 CPWHFC
3 FGABC1.0 BXABC1.0
4 FGBBO500 BTTOR500
5 FGBBO500 CPWHFC
6 FGBBO500 TRGEN500There are over 500 different parent parts that appear in col A.
Thanks
Stats -
H. Legare Coleman
AskWoody Plus
-
-
-
WSsdckapr
AskWoody LoungerAugust 20, 2002 at 9:14 pm #610054Name your ranges ParentParts for col A and col B SubParts
Enter the numbers 1-10 in A1 – A10 (you said that the most subparts is 10, change as needed
In B1 is the cell to add the ParentPart
In C1 enter in the Array formula (do not enter {}s, enter with ctrl-shift-enter)
{=IF(A1>COUNTIF(ParentParts,$B$1),””,INDEX(SubParts,SMALL(IF($B$1=ParentParts,ROW(ParentParts),””),A1)))}
Copy this into c2:c10
When B1 is changed, the subparts are displayed. If a part is not listed in table, no subparts are displayedOther options:
Try the data – filter – autofilter to get a list. You can copy this list. You can also use SUBTOTAL to get info on the items that are shown in the filter (count, avg, min, max, etc)You could also use the advanced filter to extract it out or write a macro to do all the extraction.
Steve -
macropod
AskWoody_MVPAugust 21, 2002 at 4:27 am #610219Hi Stats,
Take a look at the attached workbook. I think it’ll do what you want.
Sheet1 holds all of the Part & SubPart Nos. in Columns A & B, which are named Part & SubPart, respectively. Sheet2 extracts the SubPart list for a given Part No. (you type the required Part No. into cell A2). Column A in Sheet2 interrogates the Part list on Sheet1 to get a count of the No. of times the Part No. is repeated. This then populates the required No. of rows in Sheet2 with the Part No. Column B in Sheet2 uses the results in ColumnA for an index/match routine, offsetting the starting point each time to get the next SubPart No.
Cheers
PS: If you don’t want to see the repeated Part Nos. on Sheet2, you could format them to the same colour as the background.
Cheers,
Paul Edstein
[Fmr MS MVP - Word] -
WSStats
AskWoody LoungerAugust 22, 2002 at 11:51 am #610638Thank you very much Macropod, it worked great. FYI because our parts are alpha numeric instead of numeric as in your example, I used COUNTA instead of COUNT in col A of Sheet 2.
If I may throw a small curve ball at you, how would I get the sub parts to display across the columns instead of down the rows.
So col A would have the part, col B would have the first sub part, c would have the second sub part etc.
Thanks again for your help.
Stats -
H. Legare Coleman
AskWoody Plus -
WSStats
AskWoody LoungerAugust 22, 2002 at 3:40 pm #610740Good Day Legare,
I’m sorry I should have been more clear, attached is a partial list of exactly what MS Query outputs. I have included three main Part Numbers in col A but there are over 500. What I’m trying to accomplish is to use this as a “database” and on another workbook have the user enter the part number they want and have Excel return all of the sub parts that go into making the main part.
I guess I should have put in the attachement in the first place.
I appreciate your help. -
WSJohnBF
AskWoody Lounger -
WSsdckapr
AskWoody LoungerAugust 22, 2002 at 6:32 pm #610811Here is an attachment using the technique I mentioned on the 20th with Arrays.
I also added the list across the columns (though this is harder to read)
I also have a pulldown to select the partnumbers. (I added some columns to your table to suck out the unique entries and added some range names. If you add more items you will have to extend the range names (or just move the current last row to the end to automatically enlarge them)Hope this helps,
Steve -
H. Legare Coleman
AskWoody PlusAugust 22, 2002 at 7:37 pm #610837OK, then the VBA routine below will convert the list like you showed on Sheet1 into an new list on Sheet2 that could be used with the technique I showed in the other reply. This list will be much easier to work with.
Public Sub BuildTable() Dim I As Long, J As Long, K As Long, lKMax As Long Dim lLastRow As Long Dim oSrc As Range, oDest As Range lLastRow = Worksheets("Sheet1").Range("A65536").End(xlUp).Row - 1 Worksheets("Sheet2").Cells.Clear Set oSrc = Worksheets("Sheet1").Range("A1") Set oDest = Worksheets("Sheet2").Range("A1") oSrc.EntireRow.Copy Destination:=oDest J = 0 For I = 1 To lLastRow If oSrc.Offset(I, 0).Value oSrc.Offset(I - 1, 0).Value Then J = J + 1 K = 1 oDest.Offset(J, 0).Value = oSrc.Offset(I, 0).Value End If oDest.Offset(J, K).Value = oSrc.Offset(I, 1).Value K = K + 1 If K > lKMax Then lKMax = K Next I oDest.Range(Columns(1), Columns(lKMax)).AutoFit End Sub
-
WSStats
AskWoody LoungerAugust 27, 2002 at 4:52 pm #611802Good Afternoon Legare,
After trying all of the suggestions, I have found, for my needs, your example works best (as if there was a doubt). The other examples ran into a problem with duplicate subparts and your solution worked perfectly.
Thank you very much for your help (AGAIN!!).
Stats -
WSAladin Akyurek
AskWoody Lounger -
WSAladin Akyurek
AskWoody LoungerAugust 22, 2002 at 10:07 pm #610866Here another approach.
( 1.) Insert an additional worksheet named Admin.
( 2.) Activate Admin.
( 3.) In A1:A4 enter:{“Data”;”# of rows in use”;”# of data recs”;”# of columns in use”}
I assume in what follows the part data to be in a worksheet named Data.
( 4.) In B2 enter:
=MATCH(REPT(“z”,90),Data!A:A)
( 5.) In B3 enter:
=B2-(CELL(“Row”,Data!A2)-1)
( 6.) In B4 enter: 2 (the hardcoded number of columns in use)
( 7.) Activate Insert|Name|Define.
( 8.) Enter PTable (from parts table) in the box for “Names in Workbook”.
( 9.) Enter the following formula in the box for “Refers to”:=OFFSET(Data!$A$2,0,0,Admin!$B$3,Admin!$B$4)
This dynamic formula allows PTable to always include the changes to the data area.
(10.) Click OK.
(11.) Activate the worksheet (here referred to as Main) where the user can enter or select from a dropdown list a part in order to get a list of its subparts.
(12.) In A2 enter:=COUNTIF(INDEX(PTable,0,1),B2)
(13.) In B2 enter/select a part code, say, FG3656X4LTSPR.
(14.) In D2 enter:=IF(A2,INDEX(PTable,MATCH($B2,INDEX(PTable,0,1),0),2),””)
(15.) In E2 enter and copy across to 10 to 15 columns:
=IF(MATCH(“*”,$D2:D2,-1)<$A2,INDEX(PTable,MATCH($B2,INDEX(PTable,0,1),0)+MATCH("*",$D2:D2,-1),2),"")
If you would want to install the morefunc add-in which is downloadable from: http://longre.free.fr/english/index.html, you could also use in E2:
=IF(SETV(MATCH("*",$D2:D2,-1))<$A2,INDEX(PTable,MATCH($B2,INDEX(PTable,0,1),0)+GETV(),2),"")
Aladin
-
-
-
macropod
AskWoody_MVP
-
-
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows Update orchestration platform to update all software
by
Alex5723
1 hour, 6 minutes ago -
May preview updates
by
Susan Bradley
2 hours, 44 minutes ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
2 hours, 51 minutes ago -
Just got this pop-up page while browsing
by
Alex5723
47 minutes ago -
KB5058379 / KB 5061768 Failures
by
crown
13 hours, 14 minutes ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
15 hours, 53 minutes ago -
At last – installation of 24H2
by
Botswana12
16 hours, 38 minutes ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
6 hours, 15 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
1 day, 4 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
22 hours, 9 minutes ago -
Limited account permission error related to Windows Update
by
gtd12345
1 day, 18 hours ago -
Another test post
by
gtd12345
1 day, 18 hours ago -
Connect to someone else computer
by
wadeer
1 day, 12 hours ago -
Limit on User names?
by
CWBillow
1 day, 16 hours ago -
Choose the right apps for traveling
by
Peter Deegan
1 day, 5 hours ago -
BitLocker rears its head
by
Susan Bradley
13 hours, 50 minutes ago -
Who are you? (2025 edition)
by
Will Fastie
12 hours, 47 minutes ago -
AskWoody at the computer museum, round two
by
Will Fastie
1 day, 8 hours ago -
A smarter, simpler Firefox address bar
by
Alex5723
2 days, 4 hours ago -
Woody
by
Scott
2 days, 14 hours ago -
24H2 has suppressed my favoured spider
by
Davidhs
13 hours, 27 minutes ago -
GeForce RTX 5060 in certain motherboards could experience blank screens
by
Alex5723
3 days, 4 hours ago -
MS Office 365 Home on MAC
by
MickIver
2 days, 22 hours ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
3 days, 18 hours ago -
Flash Drive Eject Error for Still In Use
by
J9438
13 hours, 12 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
4 days, 13 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
4 days, 13 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
3 days, 16 hours ago -
Migrate off MS365 to Apple Products
by
dmt_3904
3 days, 17 hours ago -
Login screen icon
by
CWBillow
3 days, 8 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.