ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   to reverse a column (https://www.excelbanter.com/excel-worksheet-functions/115274-reverse-column.html)

Rasoul Khoshravan

to reverse a column
 
I have a column of data.
I want to reverse it. Is it possible?

as
ab
ad

change to
ad
ab
as

JBoulton

to reverse a column
 
Make a "helper" column with 1,2,3... and then sort descending on that.

"Rasoul Khoshravan" wrote:

I have a column of data.
I want to reverse it. Is it possible?

as
ab
ad

change to
ad
ab
as


Gary L Brown

to reverse a column
 
'/=================================================/
Sub FlipIt()
'reverse order of a selection
' 1st cell is last and last is first, ett
'
Dim aryCollection()
Dim LngCount As Long
Dim lngCellCount As Long
Dim rng As Range

Set rng = Application.InputBox(Prompt:="Select Range to be Searched: ", _
Title:="Range Selection...", _
Default:=Application.Selection.Address, Type:=8)

If Len(rng.Address) = 0 Then
MsgBox "No Cells were selected." & vbLf & vbLf & _
"Process Aborted.....", vbExclamation + vbOKOnly, "WARNING....."
Exit Sub
End If

rng.Select

'check for multiple range selections
If Selection.Areas.Count 1 Then
MsgBox "Multiple Range selections are not supported.", _
vbExclamation + vbOKOnly, "Warning..."
End If

If Selection.Cells.Count = 1 Then
MsgBox "You have not selected a range of cells.", _
vbExclamation + vbOKOnly, "Warning..."
Exit Sub
End If

lngCellCount = Selection.Cells.Count

'redim array
ReDim aryCollection(1 To lngCellCount)

'populate array
For LngCount = 1 To lngCellCount
aryCollection(LngCount) = Selection.Cells(LngCount).value
Next LngCount

'reverse order of cells
For LngCount = lngCellCount To 1 Step -1
Selection.Cells(lngCellCount - LngCount + 1).value = _
aryCollection(LngCount)
Next LngCount


End Sub
'/=================================================/

HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Rasoul Khoshravan" wrote:

I have a column of data.
I want to reverse it. Is it possible?

as
ab
ad

change to
ad
ab
as


David Biddulph

to reverse a column
 
The easiest way is probably to add a helper column alongside with numbers
from 1 to N.
Select the two columns, & sort by your second column in descending order,
then you can delete your helper column.
--
David Biddulph


"Rasoul Khoshravan" wrote in message
...
I have a column of data.
I want to reverse it. Is it possible?

as
ab
ad

change to
ad
ab
as




Gord Dibben

to reverse a column
 
In an adjacent column enter the numbers 1 to whatever.

Select both columns and sort on that column in descending order.


Gord Dibben MS Excel MVP

On Fri, 20 Oct 2006 00:22:49 +0900, "Rasoul Khoshravan"
wrote:

I have a column of data.
I want to reverse it. Is it possible?

as
ab
ad

change to
ad
ab
as




All times are GMT +1. The time now is 07:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com