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
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
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, 8 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.
Stevemacropod
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
-
Connecting hard drive on USB 3.2 freezes File Explorer & Disk Management
by
WSJMGatehouse
2 hours, 45 minutes ago -
Shellbag Analyser & Cleaner Update
by
Microfix
3 hours, 18 minutes ago -
CISA warns of increased breach risks following Oracle Cloud leak
by
Nibbled To Death By Ducks
4 hours, 56 minutes ago -
Outlook 2024 two sent from email addresses
by
Kathy Stevens
8 hours, 59 minutes ago -
Speeding up 11’s search
by
Susan Bradley
16 hours, 12 minutes ago -
HP Pavilion Will Not Wake Up After Being Idle for Longer Period
by
WSwalterwood44
1 hour, 15 minutes ago -
Make a Windows 11 Local Account Passwordless
by
Drcard:))
18 hours, 57 minutes ago -
Ubuntu 25.04 (Plucky Puffin)
by
Alex5723
1 day, 2 hours ago -
24H2 fixed??
by
CWBillow
16 hours ago -
Uninstalr Updates
by
jv16
1 day, 7 hours ago -
Apple zero days for April
by
Susan Bradley
12 hours, 21 minutes ago -
CVE program gets last-minute funding from CISA – and maybe a new home
by
Nibbled To Death By Ducks
5 hours, 14 minutes ago -
Whistleblower describes DOGE IT dept rumpus at America’s labor watchdog
by
Nibbled To Death By Ducks
2 days, 6 hours ago -
Seeing BSOD’s on 24H2?
by
Susan Bradley
1 day, 13 hours ago -
TUT For Private Llama LLM, Local Installation and Isolated from the Internet.
by
bbearren
1 day, 20 hours ago -
Upgrade from Windows 10 to 11
by
Holdsworth8
2 days, 15 hours ago -
Microsoft : AI-powered deception: Emerging fraud threats and countermeasures
by
Alex5723
2 days, 17 hours ago -
0patch
by
WSjcgc50
1 day, 18 hours ago -
Devices might encounter blue screen exception with the recent Windows updates
by
Susan Bradley
2 days, 11 hours ago -
Windows 11 Insider Preview Build 22631.5261 (23H2) released to Release Preview
by
joep517
2 days, 20 hours ago -
Problem opening image attachments
by
RobertG
2 days, 22 hours ago -
advice for setting up a new windows computer
by
routtco1001
3 days, 13 hours ago -
It’s Identity Theft Day!
by
Susan Bradley
14 hours, 51 minutes ago -
Android 15 require minimum 32GB of storage
by
Alex5723
3 days, 18 hours ago -
Mac Mini 2018, iPhone 6s 2015 Are Now Vintage
by
Alex5723
3 days, 18 hours ago -
Hertz says hackers stole customer credit card and driver’s license data
by
Alex5723
3 days, 18 hours ago -
Firefox became sluggish
by
Rick Corbett
1 day, 11 hours ago -
Windows 10 Build 19045.5794 (22H2) to Release Preview Channel
by
joep517
3 days, 22 hours ago -
Windows 11 Insider Preview Build 22635.5235 (23H2) released to BETA
by
joep517
3 days, 23 hours ago -
A Funny Thing Happened on the Way to the Forum
by
bbearren
2 days, 20 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.