+ Reply to Thread
Results 1 to 20 of 20

Help writing a function to use a data table based on value

  1. #1
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Help writing a function to use a data table based on value

    I need to write a function based on value entered in another cell, and to use the table a made on the sheet to determine what value to use in that cell.

    example: if e46 is 55% then e48 equals 100%, or if g46 equals 45% then g48 equals 85%. how do I write that? The table is in cells S46 through T53. see copy and paste of table below. I tried to attach a pic of the table but it wont upload.


    G.P. Comm. Rate
    >20% 0%
    20-29% 55%
    30-39% 70%
    40-49% 85%
    50-59% 100%
    60-69% 115%
    70-79% 130%
    79%< 150%
    Last edited by BLUESS02; 07-08-2020 at 10:20 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,870

    Re: need help with a formula

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: need help with a formula

    edited. apolize

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,870

    Re: Help writing a function to use a data table based on value

    Please read the yellow banner at the top of this page on how to attach a file.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Help writing a function to use a data table based on value

    It looks like a basic lookup function/lookup table using the approximate match option in one of Excel's lookup functions. Usual starting place for lookup functions is the VLOOKUP() function. Here's one of the few tutorial pages that has an example using the approximate match option: https://www.ablebits.com/office-addi...ximate-vlookup
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Help writing a function to use a data table based on value

    May be:
    In E48:
    Please Login or Register  to view this content.
    COpy to G48
    Quang PT

  7. #7
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    I manually filled in e46/e48 through j46/j48. I think it’s the range of the table cells that is messing me up.
    Attached Files Attached Files

  8. #8
    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,593

    Re: Help writing a function to use a data table based on value

    With Bebo's suggestion applied to E48 and drag copied across:

    Excel 2016 (Windows) 32 bit
    E
    F
    G
    H
    I
    J
    46
    55%
    52%
    45%
    50%
    51%
    40%
    47
    48
    100%
    100%
    85%
    100%
    100%
    85%
    Sheet: Sheet1

    I do not see a problem.
    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.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Help writing a function to use a data table based on value

    I'm not sure I understand what you are having trouble with. Here's what I did:

    1) Perhaps it is just me, but, as one who works almost exclusively with real numbers, I despise working with text strings. So, the first thing I did was to replace the text strings in S46:S53 with actual numbers. 0 in S46, 0.2 in S47, 0.3 in S48, ... 0.7 in S52, 0.79 in S53.
    2) I do not understand how you are calculating gross profit in row 46, so I have no comment there. In E48, I enter =VLOOKUP(E46,$S$46:$T$53,2,TRUE) and copy across.

    If I have understood what you are trying to do, that should work for obtaining the commission rate.

  10. #10
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    I have something wrong I guess. I did that and its coming back #n/a

  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,593

    Re: Help writing a function to use a data table based on value

    Attach a workbook showing the error so we can work out what you've done.

  12. #12
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    its because there is a range in the table and a set value in the cell I think. ill change the table and see if that fixes it.

  13. #13
    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,593

    Re: Help writing a function to use a data table based on value

    Just attach the workbook with the problem - it'll be quicker!

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Help writing a function to use a data table based on value

    Both LOOKUP() and VLOOKUP() [approximate match option] return the N/A error when lookup value is smaller than the first value in the lookup column. In both mine and Bebo's implementations, that would mean lookup value (the value in row 46) is less than 0. None of your example values for row 46 are less than 0, so neither lookup function should have returned N/A for the example values. Are your lookup values less than 0?

  15. #15
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    with error
    Attached Files Attached Files

  16. #16
    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,593

    Re: Help writing a function to use a data table based on value

    The lookup table is still text. Change it to this:

    Excel 2016 (Windows) 32 bit
    S
    T
    45
    G.P.
    Comm. Rate
    46
    0.00
    0.00
    47
    0.20
    0.55
    48
    0.30
    0.70
    49
    0.40
    0.85
    50
    0.50
    1.00
    51
    0.60
    1.15
    52
    0.70
    1.30
    53
    0.80
    1.50
    Sheet: Sheet1
    Attached Files Attached Files
    Last edited by AliGW; 07-09-2020 at 01:31 PM.

  17. #17
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    that definitely fixed it. I thank you. I guess ive never done a table with a range as a rule. Im really not understanding how you told it that its the range leading up to that number. I apologize if Im too blinded to see it.

  18. #18
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    I thank everyone involved on this, seems like such a simple fix, no idea how I just cant grasp the range function in the table. thank you all again.

  19. #19
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,870

    Re: Help writing a function to use a data table based on value

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

    Also, as a relatively new member of the forum, 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 those who helped.

  20. #20
    Registered User
    Join Date
    05-06-2020
    Location
    HOUSTON, TX
    MS-Off Ver
    OFFICE 10
    Posts
    14

    Re: Help writing a function to use a data table based on value

    Quote Originally Posted by alansidman View Post
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, 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 those who helped.
    thank you very much for the guidance as I am new. I have marked it and added to reputation. thanks again

+ 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: 3
    Last Post: 03-24-2020, 07:27 AM
  2. Replies: 3
    Last Post: 01-10-2019, 09:34 AM
  3. Replies: 5
    Last Post: 02-16-2018, 06:50 AM
  4. Replies: 8
    Last Post: 09-22-2017, 05:41 AM
  5. Excel formula bar to display the result of the formula , not the formula?
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2016, 07:15 PM
  6. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  7. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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