+ Reply to Thread
Results 1 to 27 of 27

Need help with custom formulas

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Question Need help with custom formulas

    Hi
    I'm working on a very large spreadsheet and think I need a custom formula that will automatically fill in cells on a row based on a unique number code. So for example, say the code for a particular place is 350, is there a way so that whenever 350 is entered in a1, "London" will display in b1, "John Smith" in c1, and so on? At the moment I've having to enter all the information manually in each cell and I'm sure there must be a way of automating this. I'm OK with dates and numbers, just can't work out how to get text to display based on numbers. Any help GREATLY appreciated, thank you.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,589

    Re: Need help with custom formulas

    If you have a reference table of codes, locations and names, you can use VLOOKUP to return matching data.

    For example: =VLOOKUP(A1, 'Sheet2'!$A$2:$E$500,2,FALSE)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need help with custom formulas

    Look into Vlookup and offset ...
    Alternative upload a sample file and I can set up an example of how to use them
    Elegant Simplicity............. Not Always

  4. #4
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thanks - where do I upload a file?

  5. #5
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need help with custom formulas

    Bottom right of the message area is a "Go advanced" button.... After that you get a paperclip in the menu above the message area. Select that and follow the wizard.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Need help with custom formulas

    i think what you are looking for is =vlookup().

    so you would have a list of all of your places (ie 350) and in the following columns on the same row you would have the data that you would want to "automatically" fill in.

    lets say this is the list on sheet vlookup
    cola-colb---colc... <--the dashes are only so the columns line up with the data below
    350 London John Smith...
    250 Paris---Jean Forgeron


    lets say
    on a separate page your "place" is in a1, it would be =iferror(vlookup(A1,vlookup!$A$1:$F$100,2,0),"") where A1,vlookup!$A$1:$F$100 is the data set that you have on the vlookup page, 2 is the column relative to the data set, and 0 is an exact match

    one limitation if you have multiple items associated with 350 then it will only find the first instance

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,589

    Re: Need help with custom formulas

    @Andy: how are you thinking of using OFFSET? It's a volatile function so it's best to avoid it if possible.

    Regards, TMS

  8. #8
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    example.xls
    Please see attached. I want to make it so that whenever a number is entered in column a, certain names etc appear in column b and so on.#
    Thank you!

  9. #9
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need help with custom formulas

    I use offset rather than Vlookup quite often when i'm selecting a value from a list whic relates directly to the lookup table. I know it asn't always appropriate but i prefer it to lookup when it IS possible

  10. #10
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need help with custom formulas

    Example1.xls

    There you go ... I put the Vlookup on the same sheet so you can figure out how it works

  11. #11
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    See the attached file with Vlookup.

    change the blue cell and see what's happing in the green cells.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  12. #12
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    oeldere - Are you able to save in 2003 format? I don't have 2007 and when I open your file it says some of the formulas won't work in 2003. Thanks.

  13. #13
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    Here you go (excel 2003 file)
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thanks - but all that's appearing in B1 is =_xlfn.IFERROR(G1VERT.ZOEKEN($A1,Sheet1!$A$2:$C$4,2,0),"") and in C1 is =_xlfn.IFERROR(VLOOKUP($A1,Sheet1!$A$2:$C$4,3,0),"")
    Getting #NAME? in both cells no matter what's entered in A1

  15. #15
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    And know the 2003 version without failure.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thank you! This is what I need! Now, is there a general form of that function I can use so that whenever any number between 1 and 1000 is entered in a cell in column A, the relevant corresponding managers and names appear in columns B and C?

  17. #17
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    =Vlookup($A1,Sheet1!$A$2:$C$4,2,0)

    look up cell A1

    in sheet 1 in the range A2:c24 (change the range for your need)

    take the 2th value in that row (in this example the value in the B-column).

    find an exact match (0) => 1 is the other option.

  18. #18
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thanks - this is what I'm looking for!!!
    Now, is there a way to make a single formula so that for any number between 1 and 999 entered in column A, a corresponding word will appear in columns B and C?

    I mean:

    whenever 102 is entered in a cell in column A, "Manchester" appears in the next cell in column B, "John" appears in the next cell in column C
    whenever 103 is entered in column A, "London" appears in column B and "Paul" in column C

    and so on....
    ?

  19. #19
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    What about giving a try?

    The answer is yes, but the data need to be found in the table on sheet 1.

    In this example, 103 is not in the list and you will get #N/A as answer.

  20. #20
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Sorry, ignore my last post - I hadn't refreshed and your answer came up.
    How do I change the range?

  21. #21
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    Change

    Please Login or Register  to view this content.
    in e.g.


    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thanks - almost there now. In the formula =VLOOKUP($A2,Sheet1!$A$2:$C$4,2,0) - I have changed this to (A2,Sheet1!$A$2:$C$1500,2,0) - do I need to change the 2,0 at the end to anything different?

  23. #23
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    Look at your formula in column C and notice the differance.

    P.s. you changed the formula in A2 instead of $A2.

    That can be inportant if you want to copy the formula (e.g. to the right)

  24. #24
    Registered User
    Join Date
    04-30-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Need help with custom formulas

    Thank you so much for your help. This is going to save me a huge amount of time!

  25. #25
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Need help with custom formulas

    Thanks for the feedback.

    Glad i could help.

    If you question is solved, will you mark it as solved.

    If you have other questions on this item, just ask.

    You can add points to the rep(utation) of members who helped you, by clicking on the star on the left side.

  26. #26
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,589

    Re: Need help with custom formulas

    I'm kinda confused. Nothing new there, but the final solution looks pretty much like the answer I gave you in post #2 just five minutes after you asked the question ...

    And it's taken 2 hours and 24 replies to get to this point. What am I missing?

    Regards, TMS

  27. #27
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need help with custom formulas

    jbrad,

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem. Once you have done this please send me a PM and I will remove this request.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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