+ Reply to Thread
Results 1 to 12 of 12

How to find the next occurance of a logic question

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    How to find the next occurance of a logic question

    I am normally pretty good about figuring these things out but this is beyond my abilities. In the columns below B is just 95% of A. What I want to do in column C is to put the maximum value of B over the range that corresponds until the value in A is less than that. For example for my 1st run the value would be $1,125.68 because this is the maximum amount before you fall below that in column A, or in this case hits $1,106.40. I want to be able to perform this automatically down the line (expanding the range until the logic test is true) but can't figure out how to do this. The formula would basically be the max of the range in Column B is > Column A until this is not true, then return the max in Column B for entry in Column C. Then in Column D I would run an identical analysis but return the Row identifer for the dataset. Any help is appreciated.
    Last edited by wastewater; 05-08-2009 at 04:21 PM. Reason: Added xls sheet

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to find the next occurance of a logic question

    Welcome to the forum.

    If you want help with Excel, please post workbooks and not pictures.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to find the next occurance of a logic question

    File amended with copy of spreadsheet.

  4. #4
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to find the next occurance of a logic question

    seems like I must need some type of loop command to keep checking to see whether the progressively larger max(range)> than the column A

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to find the next occurance of a logic question

    I don't understand your explanation, sorry. Someone else may.

  6. #6
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How to find the next occurance of a logic question

    You need to give more details or better explanation.
    First of all, why do you have column A listing numbers and Row 1 listing A B C?
    It's confusing to understand your logic, because you are mixing Excel column designations with your column headers.

    In Excel cell D2 you have a formula Max(C2:C11). Explain why that is?

    It shouldn't be difficult to convert the logic in to formula as long as logic is clear.

    modytrane

  7. #7
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to find the next occurance of a logic question

    I apologize for not explaining this well and will give it another shot.

    Regarding the naming, I eliminated some of that because it was confusing and resaved the spreadsheet here.

    My inputs in column C show the number I want to return, not how to get there. I have tried IF then statements but as this can go beyond the 7 or so that Excel allows I gave up on that alternative.

    I want to populate Column C based on the following logic. For row one, the 1st iteration would see if the max of (B1:B2)>A2. Since it is not, the next iteration would see if the max of (B1:B3)>B3 and so on until this condition proves true. In this case, it occurs at row 10, when the maximum of (B1:B10) is equal to $1125.68, and is greater than A10, which is equal to $1085.78. Therefore, $1125.68 is entered into cell C1.

    In row two the same process occures, i.e the 1st iteration compares the max of (B2:B3)>B3. The next iteration checks max of (B2:B4)>B4 and so on until the condition proves true, which in this instance also occurs at A10, so $1125.68 is entered into cell C2.

    This is repeated for row 3, although in this case the value entered into C3 is $1120.25 because this is the max of (B3:B10).

    Process is repeated for row 4, and in this case the greater than situation does not occur until the series analyzed reaches row 11, i.e. max of (B4:B11) is $1103.43 and is greater than A11, which is $1085.78.

    Column C would continue to be populated for as many points as I have, but the evaluation needs to proceed sequentially for each cell.
    Attached Files Attached Files
    Last edited by wastewater; 05-08-2009 at 04:27 PM.

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to find the next occurance of a logic question

    I saw this before and didn't understand either. Try this. I'm not clear on how far you want to go down column B - this goes to the bottom.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to find the next occurance of a logic question

    StephenR,
    Thanks very much for your input. I am new to VBA so am struggling through. I was not able to get your code to work so have tried a few different things without success. I tried to label this as a function so that I can place it directly in the cell I would like to return the number (C1 for instance) and got rid of the absolute reference to B1 but am not able to get this to work.

    Please Login or Register  to view this content.
    Last edited by wastewater; 05-11-2009 at 11:54 AM.

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to find the next occurance of a logic question

    Please add code tags - see "how to" at the top of the page.

    That's not right is it? Closing tag is [/code]
    Last edited by StephenR; 05-11-2009 at 11:46 AM.

  11. #11
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to find the next occurance of a logic question

    This accepts a single cell reference as an argument, e.g. =xx(B1)
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    05-07-2009
    Location
    KC, Kansas
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How to find the next occurance of a logic question

    That works great and thanks so much. I think I can even work with what I am learning to do some other things that might be useful (scary thought). I certainly appreciate you taking the time to help me out.

    Adam B.

+ 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