+ Reply to Thread
Results 1 to 11 of 11

Table Search For Codes

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Table Search For Codes

    Hi all,

    I am having trouble creating an IF AND formula to search for data. I was hoping someone could help. I have attached a file with 2 sheets.

    The sheet Glass sizes is the reporting sheet, Overall Data sheet is the source data.

    I am looking for a formula that searches the table in the Overall Data sheet for the data in cell A2, in this range A1:Z248 then fine the data in B2 and searches column AA then it pastes the data in AB of the same row. The same function is required in cell D2. This needs to be able to be copied for all blank cells.

    The data in Overall Data doesn't change.

    I have highlighted the test cells in yellow on each sheet. Hope this makes sense.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Table Search For Codes

    C2:

    =INDEX('Overall Data'!$AB$2:$AB$248,MATCH(1,('Overall Data'!$R$2:$R$248=A2)*('Overall Data'!$AA$2:$AA$248=B2),0))

    D2:

    =INDEX('Overall Data'!$AC$2:$AC$248,MATCH(1,('Overall Data'!$R$2:$R$248=A2)*('Overall Data'!$AA$2:$AA$248=B2),0))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Table Search For Codes

    Helper column to determine column of "Prefix"

    =SUMPRODUCT(('Overall Data'!$A$2:$Z$228=$A2)*COLUMN($A$2:$Z$2))/COUNTIF('Overall Data'!$A$2:$Z$228,$A2)

    in C2

    =INDEX('Overall Data'!AB$1:AB$248,AGGREGATE(15,6,ROW($A$1:$A$248)/(INDEX('Overall Data'!$A$1:$AB$248,0,$E2)=$A2)/('Overall Data'!$AA$1:$AA$248=$B2),1))

    copy across to D2

    Similar for other selections (change highlighted value for appropriate helper column)
    Attached Files Attached Files
    Last edited by JohnTopley; 01-25-2022 at 01:38 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Re: Table Search For Codes

    AliGW
    Re: Table Search For Codes

    C2:

    =INDEX('Overall Data'!$AB$2:$AB$248,MATCH(1,('Overall Data'!$R$2:$R$248=A2)*('Overall Data'!$AA$2:$AA$248=B2),0))

    D2:

    =INDEX('Overall Data'!$AC$2:$AC$248,MATCH(1,('Overall Data'!$R$2:$R$248=A2)*('Overall Data'!$AA$2:$AA$248=B2),0))

    If I copy the formula down the column I get #N/A. In the middle part of the code ('Overall Data'!$R$2:$R$248=A2) can it be changed to a bigger range to search the whole table rather than just the R column?

  5. #5
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Re: Table Search For Codes

    Hi John,

    I think my post may have not explained that I have highlighted the BDL code in the Overall Data sheet as an example. There are other table that will need searching. I have reattached the file with a 3rd Sheet to show the full tables that need searching. Hope that makes sense.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Table Search For Codes

    Re-read my post: you will need helper columns for EVERY table which I illustrated with the 2 tables in your test file.

    Given your tables are in pairs a minor adjustment to my formula would allow you to drag them down columns L and O,
    Last edited by JohnTopley; 01-25-2022 at 02:33 PM.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Table Search For Codes

    And you need to get the "Prefixes" in your table aligned with your data table as you have inserted a blank space "33 (78/60)" vs "33(78/60)"

    Columns G and R have corrected values: need to copy/paste values into your tables.
    Attached Files Attached Files
    Last edited by JohnTopley; 01-25-2022 at 03:22 PM.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Table Search For Codes

    I assumed each prefix was associated with a single column but I discovered that FPP-V U3 is in more than one column so the SUMPRODUCT approach to finding the column will not work.

    Several others have the same problem: if this is not an error you may need VBA to provide a solution.

    See attached.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Table Search For Codes

    Please Login or Register  to view this content.
    I discovered there are duplicate values for a given Prefix/Code: as an example, see BDL in attached
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Re: Table Search For Codes

    Hi John,

    Thank you for all your work, this is amazing, I can fill in the few blanks. Really appreciate it.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Table Search For Codes

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search for common post codes
    By SouthWesty in forum Excel General
    Replies: 4
    Last Post: 12-03-2020, 11:15 AM
  2. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-01-2020, 06:46 AM
  3. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-29-2020, 12:06 PM
  4. Replies: 16
    Last Post: 07-11-2017, 04:22 PM
  5. [SOLVED] search for 2 'codes' on 1 line to return a value
    By Nae2016 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-22-2016, 10:48 PM
  6. Excel 2003 Macro to search for Zip Codes
    By kjwaller in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2009, 03:40 AM
  7. Search codes based on time range
    By Statsman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2008, 09:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1