+ Reply to Thread
Results 1 to 6 of 6

Checking Range, altering out of bounds, checking result against table

  1. #1
    Registered User
    Join Date
    04-11-2016
    Location
    England
    MS-Off Ver
    -
    Posts
    3

    Unhappy Checking Range, altering out of bounds, checking result against table

    So this is the spreadsheet I'm working on:
    Screen Shot 2016-04-11 at 10.48.57.png

    I want to be able to have a cell, lets call it "a1" have a numerical value i can control.
    I then want to check that number to see if it's a value between 3 and "b2".
    If it's within that range, it retains its value.
    If it's higher, it becomes "b2".
    If it's lower, it becomes 3.
    I then want to check the resulting value against this table's column "r". Then get the value of column "s".

    For example: I enter 17 into "a1".
    It checks the number 17, recognising it isn't below 3 or above "b2".
    It then checks column "r" for the number 17.
    It then checks across that row to column "s", and tells me it is "30.56%"

    Another example: I enter -20 into "a1".
    It checks the number -20, recognising it is below 3.
    It makes the number 3.
    It then checks column "r" for the number 3.
    It then checks across that row to column "s", and tells me it is "100.00%"

    My question is, what would I need to enter into a cell make this happen?


    PS: I'm very new to spreadsheets and functions, bear that in mind with any explanations. And apologies if the title or anything else isn't an accurate description of my problem!

    Thanks in advance!
    Last edited by Sillystring; 04-11-2016 at 05:55 AM. Reason: updated the screenshot

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

    Re: Checking Range, altering out of bounds, checking result against table

    Welcome to Excel Forum!

    A little tip for you, the majority of forum members can't see .png images in posts, it's better to attach a sample workbook (with any confidential data removed / fictionalised).

    You can't change make a value change in the cell in which you type it with a formula, that needs vba. Given that you're very new to things, maybe a simpler approach would be better.

    Enter your test value into A1

    Enter this formula into A2, to get the corrected value A1, 3 or B2 based on your specified criteria.

    =MEDIAN(A1,3,B2)

    Then in A3, enter this formula to get the percentage figure from column S

    =VLOOKUP(A2,$R$1:$S$100,2,0)

    You might need to change the cell format of A3 for the result to correctly show as percentage.

  3. #3
    Registered User
    Join Date
    04-11-2016
    Location
    England
    MS-Off Ver
    -
    Posts
    3

    Re: Checking Range, altering out of bounds, checking result against table

    Thanks for the reply, i didn't know that most users cant see images.

    I did know that a1 is where i'd enter the value to be tested, and not be where the formula for the calculation is entered, i'll have another results table for that!

    1) I'm not sure yet if =MEDIAN(A1,3,B2) is what i'm looking for, I will test it to find out though.
    2) is there a way to combine the =median and =vlookup parts of this into one formula (presumably using brackets?) just to save room on the spreadsheet? (I was using =vlookup to grab data from the table in the screenshot I posted prior to asking this, but I realised it wasn't accounting for values outside the range of 3 to b2, and i couldn't for the life of me figure out how to a: make all values lower than 3 become 3, higher than b2 become b2, and b: combine the formula in one cell. -i got confused by all the brackets and the general language required)

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

    Re: Checking Range, altering out of bounds, checking result against table

    You can nest the 2 functions together easily enough, because you said that you were very new to spreadsheets, etc. I kept them separate to make it easier for you to see what each part was doing.

    =VLOOKUP(MEDIAN(A1,3,B2),$R$1:$S$100,2,0)

    As I can't see what is in B2, I'll assume 20.

    With 17 in A1, the median of 3,17,20 would be 17 (A1)
    With -20 in A1, the median of -20,3,20 would be 3
    With 40 in A1, the median of 3,20,40 would be 20 (B2)

    It will work fine as long as you always feed it 3 values, if A1 is empty, or contains anything other than a number then it will give an incorrect result, which based on a value of 20 in B2 would be 11.5, the average of 3 and 20, or (3+20)/2.
    Last edited by jason.b75; 04-11-2016 at 06:31 AM.

  5. #5
    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,001

    Re: Checking Range, altering out of bounds, checking result against table

    Try

    =VLOOKUP(MEDIAN(A1,3,B2),$R$1:$S$100,2,0)

  6. #6
    Registered User
    Join Date
    04-11-2016
    Location
    England
    MS-Off Ver
    -
    Posts
    3

    Re: Checking Range, altering out of bounds, checking result against table

    Excellent, thanks jason, i'll try it out but i'm sure it'll work perfectly, I did simplify the example I was giving to avoid confusion, "a1" is actually the sum of a combination of a long series of calculations of other cells already (it branches out like a tree) , many of which I listed out in separate cells instead of combining the formulas just to visualise the calculations. "b2" is actually a fairly simple set of calculations with another variable input which calls from a different table, hence my knowledge of using =vlookup. I know the math behind it all, but I often do find i'm stumbling in the dark a bit by not knowing the formula language, so you explaining this simply really helped.

    As i say, ill try this out just to make sure, but it looks like it'll do the trick.

    Thanks aswell to other people that replied!

    Edit: yep, worked perfectly, used variations of this: "=vlookup(MEDIAN((($B2+$H$22)-(B$19+$H$21)),3,(B$21+B$21)),$R$41:$V$64,2,0)" to fill all columns of the new table quickly and easily! (also hah, the example I just chose to post even references b2 ^^)

    10/10 very helpful, thanks!
    Last edited by Sillystring; 04-11-2016 at 08:07 AM.

+ 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. [SOLVED] Checking the result of a forumula
    By StormStrikes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2015, 11:57 AM
  2. Checking in two tables and display the result in Excelsheet.
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-03-2014, 06:58 PM
  3. Checking if a table already exists
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2013, 09:11 AM
  4. Replies: 3
    Last Post: 01-06-2012, 02:53 PM
  5. Replies: 3
    Last Post: 01-03-2012, 10:54 PM
  6. Checking Web Page(s) within a table.
    By Madlock in forum Excel General
    Replies: 4
    Last Post: 09-19-2010, 06:20 PM
  7. Code loop through two tables checking and altering
    By excel_lover in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 11-14-2008, 05:50 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