Reversing coulumn

D

Del

I have a coulumn with data in seperate rows i.e. 22,25,48,96,etc. Is there
an easy way change the data around so that it reads etc,96,48,25,22

TIA
 
K

Ken Wright

With your data in say A1:A100, in B1 put 1, in B2 put 2 and then fill down to
B100. Now select A1:B100 and sort on B in descending order. When done just
delete the data in B. Change ranges to suit.
 
L

Leo Heuser

If only some of the cells are to be
changed, this routine will do the job.
Make changes to mirror the actual
setup in

Col = "B"
ChangeCells = Array(22, 25)
WithCells = Array(96, 48)

The routine is inserted in a general module:
From the sheet: <Alt><F11>, menu: Insert >
Module, copy and paste the code to the
righthand window.
Return to the sheet with <Alt><F11>,
save the workbook and run the code from
Tools > Macro > Macros.
It is assumed, that the cells to be changed
do not contain formulae.



Sub ChangeRows()
'Leo Heuser, 1 Feb. 2004
Dim ChangeCells As Variant
Dim Col As String
Dim Counter As Long
Dim Dummy As Variant
Dim WithCells As Variant

Col = "B"
ChangeCells = Array(22, 25)
WithCells = Array(96, 48)

With ActiveSheet
For Counter = LBound(ChangeCells) To UBound(ChangeCells)
Dummy = .Cells(ChangeCells(Counter), Col).Value
.Cells(ChangeCells(Counter), Col).Value = _
.Cells(WithCells(Counter), Col).Value
.Cells(WithCells(Counter), Col).Value = Dummy
Next Counter
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top