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.
Bookmarks