+ Reply to Thread
Results 1 to 9 of 9

how can i simplify this Formula?

  1. #1
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    how can i simplify this Formula?

    I have a formula that looks to a cell and changes it. Part of the formula simply looks for "-" and takes off the spaces on either side and shrinks it so "47 - Left" becomes "47L". The big part of the formula changes names like "Cerebelum_4_5 - Right" to "Cer4,5R". Because the names are all different and the order in which I get the data changes every time I cant just assign a name to a helper column. I have to look where the name is in the column this time then change it.

    The last part of the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    works great for all the number and letter names like "1 - Left"

    for the ones with long names I have to write an IF statement for each name and there are 37 so I have 37 nested IF statements. It all works but I would like to see if there is a better way to do it.

    Here is the formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Ill upload an example. In the example the formula is in B1 and dragged down to the end. The data is in D1 - Again the order of the data changes every time get new data.
    Attached Files Attached Files

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: how can i simplify this Formula?

    a table with accordances and VLOOKUP

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

    Re: how can i simplify this Formula?

    Where your comparisons are just a straight substitution, e.g.:

    Cerebelum_Crus2 - Left … CerCru2L
    Cerebelum_Crus2 - Right … CerCru2R
    Cerebelum_Crus1 - Left … CerCru1L
    Cerebelum_Crus1 - Right … CerCru1R
    Cerebelum_3 - Left … Cer3L
    Cerebelum_3 - Right … Cer3R
    Cerebelum_4_5 - Left … Cer4,5L
    Cerebelum_4_5 - Right … Cer4,5R
    Cerebelum_6 - Right … Cer6R

    and so on, you could just set up a small table by putting the longer strings in a column somewhere on the worksheet and the abbreviations in the adjacent column (suppose in columns X and Y), and then you could use this formula to change them accordingly:

    =VLOOKUP(D1,X:Y,2,0)

    so you won't need many of those multiple IFs. If you do that table down to:

    Sub_Thalamus - Right … SubThaR

    then I think your formula would become:

    =IFERROR(VLOOKUP(D1,X:Y,2,0),IFERROR(,LEFT(D1,(FIND(" - ",D1,1)-1))&MID(D1,(FIND("-",D1)+2),1)),D1))

    then you can copy it down.

    Hope this helps.

    Pete

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: how can i simplify this Formula?

    this is how I did it. First, I agree with Pete and Tim, so I set up a small table in columns M and N, then used a left and right formula to get most of your other list like 13pL etc.
    so the formula is ...
    =IFERROR(INDEX($M$1:$M$38,MATCH(D1,$N$1:$N$38,0)),LEFT(D1,SEARCH(" - ",D1)-1)&RIGHT(MID(D1,SEARCH("- ",D1),3),1))
    where the index match looks against your table I set up in cells M1 through N38.
    Attached Files Attached Files
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: how can i simplify this Formula?

    I was working on it for a while so when I hit refresh I now see it isn't that much different than what Pete gave you, that is what I get for being so slow (LOL).

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

    Re: how can i simplify this Formula?

    I didn't spend time setting up the table to test it out fully !!

    Pete

  7. #7
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: how can i simplify this Formula?

    That works great thanks all

  8. #8
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: how can i simplify this Formula?

    Tim, just curious about efficiency. Is vlookup more taxing one Excell than = ? I was going under the impression vlookup took more computing power so I was trying to look for a solution that allowed me to just use = in a cell. The program I'm using is bloated already and I would have to add about 2k vlookup formulas instead of 2k = formulas.

  9. #9
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: how can i simplify this Formula?

    kevinu, two thngs:
    table is sorted in alphabetical order
    formula looks this way VLOOKUP(string, table, column number)
    it works very fast

+ 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. Simplify Formula
    By ja3k14c in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-02-2019, 07:41 AM
  2. [SOLVED] Need help to simplify formula without VBA
    By seercoven in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-31-2015, 10:19 AM
  3. Can anyone help simplify this formula
    By Rene Ford in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-07-2014, 07:49 AM
  4. [SOLVED] Simplify the formula
    By eing in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-03-2013, 12:44 AM
  5. simplify formula
    By steph67 in forum Excel General
    Replies: 9
    Last Post: 12-19-2010, 12:03 PM
  6. Simplify formula
    By ShockG in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2008, 09:21 AM
  7. Simplify a Formula
    By alan_stephen75@ in forum Excel General
    Replies: 8
    Last Post: 02-20-2008, 09:32 AM

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