+ Reply to Thread
Results 1 to 6 of 6

shorten very long formula

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    2

    shorten very long formula

    hi all, i currently have this formula in a worksheet of mine, and although it works correctly very well, as you can see its very long, i wondered if there is any way i can shorten down the size of it.
    i have used concatenate but im sure there is another better way of doing this

    =CONCATENATE(IF(B132="Arsenal",VLOOKUP(C133,'div1'!$X$3:$Y$67,2,FALSE), IF(B132="Blackpool",VLOOKUP(C133,'div1'!$X$70:$Y$134,2,FALSE), IF(B132="Burnley",VLOOKUP(C133,'div1'!$X$137:$Y$201,2,FALSE), IF(B132="Chelsea",VLOOKUP(C133,'div1'!$X$204:$Y$268,2,FALSE), IF(B132="Coventry",VLOOKUP(C133,'div1'!$X$271:$Y$335,2,FALSE), IF(B132="Crystal Palace",VLOOKUP(C133,'div1'!$X$338:$Y$402,2,FALSE), IF(B132="Derby",VLOOKUP(C133,'div1'!$X$405:$Y$469,2,FALSE), IF(B132="Everton",VLOOKUP(C133,'div1'!$X$472:$Y$536,2,FALSE), IF(B132="Huddersfield",VLOOKUP(C133,'div1'!$X$539:$Y$603,2,FALSE), IF(B132="Ipswich",VLOOKUP(C133,'div1'!$X$606:$Y$670,2,FALSE), IF(B132="Leeds",VLOOKUP(C133,'div1'!$X$673:$Y$737,2,FALSE), IF(B132="Liverpool",VLOOKUP(C133,'div1'!$X$740:$Y$804,2,FALSE), IF(B132="Man City",VLOOKUP(C133,'div1'!$X$807:$Y$871,2,FALSE), IF(B132="Man United",VLOOKUP(C133,'div1'!$X$874:$Y$938,2,FALSE), IF(B132="Newcastle",VLOOKUP(C133,'div1'!$X$941:$Y$1005,2,FALSE), IF(B132="Nottm Forest",VLOOKUP(C133,'div1'!$X$1008:$Y$1072,2,FALSE), IF(B132="Southampton",VLOOKUP(C133,'div1'!$X$1075:$Y$1139,2,FALSE), IF(B132="Stoke",VLOOKUP(C133,'div1'!$X$1142:$Y$1206,2,FALSE), IF(B132="Tottenham",VLOOKUP(C133,'div1'!$X$1209:$Y$1273,2,FALSE), IF(B132="West Brom",VLOOKUP(C133,'div1'!$X$1276:$Y$1340,2,FALSE), IF(B132="West Ham",VLOOKUP(C133,'div1'!$X$1343:$Y$1407,2,FALSE), IF(B132="Wolves",VLOOKUP(C133,'div1'!$X$1410:$Y$1474,2,FALSE), )))))))))))))))))))))))

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: shorten very long formula

    Hi and welcome.

    Might be easier to help if we can see the file. Could you attach it?

    Click on "Go Advanced" below your reply then scroll down to "Manage Attachments" to open the upload window.

    BSB

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: shorten very long formula

    With a list of the teams that are used in your formula somewhere in the sheet, you could shorten it to.

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


    This is assuming that the number of rows remains consistent for all teams listed, I only checked the first 5.
    Last edited by jason.b75; 06-22-2019 at 04:14 PM.

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,843

    Re: shorten very long formula

    I would probably do something like this (see attachment).
    I'm using the Excel Table feature. A dropdown menu with the teams and below that a formula that builds an Excel Table reference from the team name.
    I then use that reference with INDIRECT in a VLOOKUP.
    A bit cumbersome to set up (yup, that's me alright) but once set up it is pretty tidy.
    I didn't complete the table, too much work. To complete it, select a column, hit Ctrl + +, copy the header name from the left on to the new column (it will be the same name but with a 2 in the end).
    Attached Files Attached Files
    Last edited by Jacc; 06-22-2019 at 04:50 PM.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  5. #5
    Registered User
    Join Date
    10-11-2012
    Location
    edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: shorten very long formula

    Quote Originally Posted by jason.b75 View Post
    With a list of the teams that are used in your formula somewhere in the sheet, you could shorten it to.

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


    This is assuming that the number of rows remains consistent for all teams listed, I only checked the first 5.
    ive just tried using this and adjusting the code to suit the cell i tried it on, and it works perfectly, my questions would be this could be adjusted to suit any amount of teams as long as they are added to the list and follow the same size of 67? [i currently have just 22 teams on it, but i would like to add others] and I could adjust the 67 to whatever i want as well i presume? if i wated only 42 say, i would adjust the numbers at the end to suit? my other question is i understand most of the formula, but could you break it down and explain in dummies english for me how the code works? sorry my excel knowledge is basic hence my question on here

    I have attached a file with images to let you see what I mean.
    Attached Files Attached Files
    Last edited by dioxide; 06-22-2019 at 05:39 PM.

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: shorten very long formula

    As long as the pattern remains consistent, it would work for any number of teams with any number of rows.

    This bit of the formula is used to create the range from one of your original vlookup formulas, OFFSET('Div1'!$X$3,(MATCH(B132,List!$A$1:$A$20,0)-1)*67,0,65,2) so breaking it down:-
    OFFSET('Div1'!$X$3, the first vlookup started in X3, so this is the base point where the offset needs to start.
    (MATCH(B132, the critera from your repeated IF logical tests.
    List!$A$1:$A$20 a list to compare the criteria to.
    ,0) 0 is the same as FALSE in vlookup or match (exact match to criteria).
    -1) an adjustment to the result of MATCH, for the formula to work, the first result needs to be 0, the second needs to be 1, etc. MATCH will return 1 and 2, so subtracting 1 gives what we need.
    *67 number of rows between the starting point of each vlookup range. X3 to X70 = 67 rows.
    ,0 the formula is already set to column X, so no change needed hence 0 is used here.
    ,65,2) the number of rows and columns in each lookup range, X3:Y67 = 65 rows and 2 columns.

    Hopefully that will make sense.

+ 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. How to use AND & IF and shorten a long formula
    By VisionSmart in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-16-2019, 06:45 AM
  2. [SOLVED] How to shorten Too Long Countif formula
    By putraguevara in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-10-2019, 04:12 PM
  3. [SOLVED] [SOLVED] formula too long, not sure how to shorten
    By Jane in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 01-18-2016, 11:54 PM
  4. Shorten very long vlookup formula
    By pframpton in forum Excel General
    Replies: 2
    Last Post: 08-27-2015, 09:42 AM
  5. Long formula, need to shorten
    By BlairStevenson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-06-2014, 12:23 PM
  6. [SOLVED] Too Long formula to shorten help
    By lapot in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-14-2014, 07:51 AM
  7. [SOLVED] Shorten a very long Formula
    By Floydlevedale in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2013, 09:39 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