+ Reply to Thread
Results 1 to 3 of 3

Macro logic: extract higher/lower values based on Unique Cell

  1. #1
    Forum Contributor
    Join Date
    06-03-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007 / Excel 2010
    Posts
    106

    Macro logic: extract higher/lower values based on Unique Cell

    This is a logic based macro that needs to compare values in 1 column above a specific cell and take action until the column has no more data. Here's what I'm trying to do (and I've also attached a sample of desired results):

    1) I want user to input starting cell. So I need to create a button for that.

    2) This is where the logic begins and I'm having difficulty.
    From cell defined in button, I move up one cell in that column and compare that value to the original cell.

    If the value is greater than original cell then logic needs 2 outcomes:

    a) move up 1 cell in column and if that value is less than original cell, then extract that value and copy that value one cell to the right or 1c.
    b) move up 1 cell in column and if that value is greater than original cell, then move up again, until find lesser value than original cell. Once we find value less than original cell, extract value and copy value one cell to the right or 1c.

    Once lesser value has been copied to new cell, logic is now:
    a) move up 1 cell in column and if that value is greater than original cell, then extract that value and copy that value one cell to the right or 1c.
    b) move up 1 cell in column and if that value is less than original cell, then move up again, until find greater value than original cell. Once we find value greater than original cell, extract value and copy value one cell to the right or 1c.

    At any point in the process if we find a value equal to the starting cell, we ignore it and the logic continues. The logic needs to continue flip flopping like this to top of column.

    OR
    Here's the logic now in reverse I need:

    If after moving up 1 cell of original cell, the value is less than original cell then logic needs 2 outcomes:

    a) move up 1 cell in column and if that value is greater than original cell, then extract that value and copy that value one cell to the right or 1c.
    b) move up 1 cell in column and if that value less than original cell, then move up again, until find greater value than original cell. Once we find value greater than original cell, extract value and copy value one cell to the right or 1c.

    Once greater value has been copied to new cell, logic is now:
    a) move up 1 cell in column and if that value is less than original cell, then extract that value and copy that value one cell to the right or 1c.
    b) move up 1 cell in column and if that value is greater than original cell, then move up again, until find lesser value than original cell. Once we find value lesser than original cell, extract value and copy value one cell to the right or 1c.

    Again, at any point in the process if we find a value equal to the starting cell, we ignore it and the logic continues. The logic needs to continue flip flopping like this to top of column.

    I hope someone out there can understand this. Been trying very hard to figure this out, but can't seem to get it. I understand the logic but trying to program the macro is proving more difficult than expected. Attached are 2 files demonstrating showing how the logic needs to flip back and forth as moving up the column depending on the first value above original cell.
    Attached Files Attached Files
    Last edited by ExcelQuestFL; 06-13-2009 at 04:50 PM.

  2. #2
    Forum Contributor
    Join Date
    06-03-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007 / Excel 2010
    Posts
    106

    Re: Macro logic to extract higher/lower values based on Unique Cell

    Apologies to bump this again. Having difficulties operating this function. I am a beginner and learning as much as possible. Please help.....

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro logic:Only for serious users - extract higher/lower values based on Unique

    I just had a quick look, perhaps something like the below though it's not clear what happens if the value preceding that selected is = to selected cell... (ie if F26=F27 in your sample file)


    Please Login or Register  to view this content.
    EDIT:
    On an aside I reverted your title - keep in line with the sort of thing you would enter in Google ... you would not search "Serious Users" etc... this is not going to filter out people who look at it, quite the contrary... most people frequenting the board would consider themselves above average I'm sure.
    Last edited by DonkeyOte; 06-13-2009 at 03:18 AM.

+ 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