Here's a formula that will do it.Hello All,
How can I take a list of several thousand rows in Column A, get the last column and just completely flip the list from the bottom to the top?
Again as always thanks for any and all help!
Kurt
Try this below, changing the last cell in the column ($A$7 to whatever your last cell is). Copy down.Hello All,
How can I take a list of several thousand rows in Column A, get the last column and just completely flip the list from the bottom to the top?
Again as always thanks for any and all help!
Kurt
Excel Workbook | ||||
---|---|---|---|---|
A | B | |||
1 | ||||
2 | 1 | 6 | ||
3 | 2 | 5 | ||
4 | 3 | 4 | ||
5 | 4 | 3 | ||
6 | 5 | 2 | ||
7 | 6 | 1 | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | =INDIRECT("A"&ROWS(A2:$A$7)+1) | |
B3 | =INDIRECT("A"&ROWS(A3:$A$7)+1) | |
B4 | =INDIRECT("A"&ROWS(A4:$A$7)+1) | |
B5 | =INDIRECT("A"&ROWS(A5:$A$7)+1) | |
B6 | =INDIRECT("A"&ROWS(A6:$A$7)+1) | |
B7 | =INDIRECT("A"&ROWS(A7:$A$7)+1) |
Sub flipstack()
Dim r As range
Dim i As Integer, j As Integer
Dim temp As Variant
Set r = range(range("A2"), range("A2").End(xlDown))
j = r.Count
i = 1
Do While i < j
temp = r.Cells(i).Value
r.Cells(i).Value = r.Cells(j).Value
r.Cells(j).Value = temp
i = i + 1
j = j - 1
Loop
End Sub
Sub flipstack()
'-------------------------------------------------------------------------------------
' Reverse contents of cell in single column
' Performs swap of first with last working towards the middle of the range
'-------------------------------------------------------------------------------------
Dim r As range, top As range
Dim i As Long, j As Long
Dim temp As Variant
Set top = range("A2") ' Define position of top cell
Set r = range(top, top.End(xlDown)) ' Define range to flip
i = 1 'Initialize for first cell in range
j = r.Count 'Initialize for last cell in range
' Loop until the top and bottom cells being swaped meet in the middle
Do While i < j
temp = r.Cells(i).Value 'Assign Value to temp var
r.Cells(i).Value = r.Cells(j).Value 'Overwrite top with bottom value
r.Cells(j).Value = temp 'Overwrite bottom with temp var
i = i + 1 'Increment to next from top to swap
j = j - 1 'Decrement to next from bottom to swap
Loop
End Sub
The column A looks like this:
A
123
566
788
999
786
for several thousand rows. I want to keep the numbers in order but just flip them from bottom to top.