+ Reply to Thread
Results 1 to 16 of 16

Breaking down cell value for INDEX/MATCH

  1. #1
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Question Breaking down cell value for INDEX/MATCH

    Cell G10 will ALWAYS have a value under the following format:

    XX-14-##, XXX-15-##, XXXX-14-##

    Where the first letters (they will always be letters) BEFORE the hypen ("-"), represent a Contractor code

    The 2 numbers between the hyphens represent the year (14 = 2014)

    The LAST 2 numbers (the ones AFTER THE HYPHEN) represent the district.

    Based on the value of G10, how can I have J5 give me the district (I have a separate tab that lists the districts: column D is district number, column E is District Name (what I want), column F is Region name)?

    Based on G10, How can I have J6 give me the region?

    Based on G10, How can I have J9 give me the contractor name(the separate tab that I have also lists the contractors: column A is the contractor code, column B is the Contractor name.)?
    Note: the code SCE will NEVER APPEAR, but instead MW, ME, NC, DE, OR, RLN, RLS, SJC, SJOA.

    If an upload is needed, let me know and I'll put it up.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Breaking down cell value for INDEX/MATCH

    A combination of string manipulations (LEFT, RIGHT, FIND) and some vlookups.
    Attached Files Attached Files
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Daffodil, I see from your upload it works, but not when I transcribe over the formula to my spreadsheet.

    Let me upload mine, so maybe you can see why it doesn't migrate over nicely.

    Just as an example, there are 10 different tab examples that show how J5, J6, and J9 are supposed to look like. My vlookup range is on "Reference List" tab.

    By the way, loved your Lord of the Ring Humor. lol
    Attached Files Attached Files

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Breaking down cell value for INDEX/MATCH

    Ahh, I remember this attachment.

    I worked for a couple of hours yesterday trying to come up with some code to automate your new tab generation.

    --

    Oh the formulas all look good to me, your template is just generating an error because there's no code in G10.

    To prevent the error, you could encapsulate each formula in =IFERROR(formula,"") which will create a blank cell.
    Attached Files Attached Files
    Last edited by daffodil11; 11-26-2014 at 04:45 PM.

  5. #5
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Quote Originally Posted by daffodil11 View Post
    Ahh, I remember this attachment.

    I worked for a couple of hours yesterday trying to come up with some code to automate your new tab generation.
    Oh, how interesting. Did you get anything working with that?


    Quote Originally Posted by daffodil11 View Post
    Oh the formulas all look good to me, your template is just generating an error because there's no code in G10.
    Oh yeah huh... duh!

    Quote Originally Posted by daffodil11 View Post
    To prevent the error, you could encapsulate each formula in =IFERROR(formula,"") which will create a blank cell.
    Thanks. Will do.

    Daffodil, it's almost there. I noticed that on J9 (the vendor/contractor), when G10 starts with MW, ME, OR, NC, DE, RLN, RLS, SJOA, or SJC it doesn't populate J9 as SCE, just like the example sheets show them. (See Reference List tab)
    G10 will never start with SCE... only the region code (MW, ME, OR, NC, DE, RLN, RLS, SJOA), but I do want it to say SCE on J9.

    Other than that, it's getting better.

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Breaking down cell value for INDEX/MATCH

    That's because the lookup is matching to first column, and pulling second.

    I've moved your Region table over, and extended your contractor lookup so that it finds things correctly. All tabs have had the formulas applied to them.

    Maybe I'll stay in the office and revisit the worksheet creation and see if I can make any new headway.
    It feels slightly out of my league, but I've surprised myself before.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Daffodil... that did it!

    Whatever you can do for that OTHER issue with the check sheets that would be great... but not as great as the way you name the excel files.

    If you do still feel its out of your league... check that forum thread... there's been some headway, but it's not 100% yet. http://www.excelforum.com/excel-prog...ed-sheets.html

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Breaking down cell value for INDEX/MATCH

    I perused stnkynts code and it's definitely a few notches beyond my capabilities.
    This year I've only taught myself simple loops, change events, a couple UDFs, and Outlook interactions.

    I understand most of it though, and will post a revision to his code to include the above logic for J5, J6, and J9.

  9. #9
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Daffodil (or anyone else), the working formula needs a minor tweaking due to work scope changes at work.

    The following G10 cell value of MW-15-44 would be broken down by these 2 formulas to give me its corresponding VLOOKUP value:

    J5=IFERROR(VLOOKUP(RIGHT($G$10,2)*1,'Reference List'!$D$1:$F$37,2,0),"") WHICH WOULD GET THE 44 FROM G10 and use it for a VLOOKUP.
    J6=IFERROR(VLOOKUP(RIGHT($G$10,2)*1,'Reference List'!$D$1:$F$37,3,0),"") WHICH WOULD GET THE MW FROM G10 and use it for a VLOOKUP.

    Now though, NEW WORK can make the G10 have a -TR at the end, so G10 = MW-15-44-TR

    How can I have my J5 & J6 formulas tweaked to look at:
    J5 - Look at the 2 numbers AFTER THE second dash "-"
    J6 - Look for all the characters BEFORE the first dash "-"

    right now it's reading it from the right of G10, but with values such as MW-15-44-TR coming along (the "-TR" being new), now using RIGHT excel formula won't cut it.

  10. #10
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Thanks again to you Daffodil, and to anyone else who can help.

  11. #11
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    If anyone has anything, that would be great :-)

  12. #12
    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,215

    Re: Breaking down cell value for INDEX/MATCH

    try

    =LEFT(G10,2)... MW

    =MID(G10,7,2) .... 44

  13. #13
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    Quote Originally Posted by JohnTopley View Post
    try

    =LEFT(G10,2)... MW

    =MID(G10,7,2) .... 44
    John... that worked!!!

    I substitued J5=IFERROR(VLOOKUP(RIGHT($G$10,2)*1,'Reference List'!$D$1:$F$37,2,0),"") with what you gave me to get

    J5=IFERROR(VLOOKUP(MID(G10,7,2)*1,'Reference List'!$D$1:$F$37,3,0),"") and it worked perfectly!!

    Same worked for J6.

    What is MID?

  14. #14
    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,215

    Re: Breaking down cell value for INDEX/MATCH

    MID function enables to look for text starting at a given position and for a stated length.

    A1 ="ABCDEFG"

    =MID(A1,4,2) will return "DE" i.e. start at position 4 for length 2

  15. #15
    Forum Contributor
    Join Date
    10-23-2004
    Location
    Los Angeles
    MS-Off Ver
    2010
    Posts
    253

    Re: Breaking down cell value for INDEX/MATCH

    John... I used it and I got an error.

    Some logs start with 2 characters

    MW-15-32
    ME-15-22
    NC-15-39

    Others have MORE THAN 2 CHARACTRES before the first dash. Ex:
    HWI-15-32
    HTE-15-47
    WEISS-15-44
    HTE-15-47-TR

    Having this said, I stumbled upon the scenario where I used the log HWI-15-32. Since before the first dash "-" I have 3 characters, the MID formula you gave me won't work. It will only work if BEFORE THE FIRST DASH it is 2 characters.

    How can the formula be changed so that it reads ALL THE CHARACTERS BEFORE THE FIRST DASH?

    I would want J5 TO BE...

    HWI-15-44 = HWI
    MW-15-44 = MW
    ASPL-15-32-TR = ASPL
    NC-15-39-TR = NC
    ME-15-34 = ME

    Pretty much anything that's BEFORE the first dash.

  16. #16
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,737

    Re: Breaking down cell value for INDEX/MATCH

    Quote Originally Posted by JPWRana View Post
    How can the formula be changed so that it reads ALL THE CHARACTERS BEFORE THE FIRST DASH?
    Try this:

    =LEFT(G10,FIND("-",G10)-1)

    Hope this helps.

    Pete

+ 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. Replies: 6
    Last Post: 04-30-2014, 02:42 AM
  2. Replies: 4
    Last Post: 01-13-2014, 04:16 AM
  3. [SOLVED] Index Match from a cell populated from index match
    By MarcLewis in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-15-2013, 05:30 AM
  4. A- Z Sort breaking with Index Match
    By Vaslo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-15-2013, 05:22 PM
  5. Replies: 3
    Last Post: 05-08-2013, 02:10 PM

Tags for this Thread

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