cell order

S

scott

if i have a list of names in rows a1:a40 and i want to copy that list to
cells b1:b40 BUT i want the new list to be the exact reverse of the first
one. i got the copy and paste down but how do i "reverse" or "invert" the
selection? thanks in advance
 
D

Don Guillett

One way
Sub invertlist()
rev = 1
For i = 5 To 1 Step -1
Cells(rev, "k").Value = Cells(i, "J").Value
rev = rev + 1
Next i
End Sub
 
G

Gary''s Student

1. copy A1 thru A30 to B1 thru B30
2. In C1 thru C30 enter 1 thru 30
3. sort cols B & C by C descending
 
S

scott

i'm new to macros and i'm assuming that's what this is. where do my cell
references go
 
S

scott

and how would i eliminate any blank rows at the bottom of the original list
from appearing at the top of the new list?
 
D

Don Guillett

I have changed the columns to suit and this will take care of blank cells at
the bottom. Just put in a module and execute the macro. It might be easier,
for you, to just put numbers in a helper column and sort by that column.

Sub invertlist()
rev = 1
For i = Cells(Rows.Count, "a").End(xlUp).Row To 1 Step -1
Cells(rev, "b").Value = Cells(i, "a").Value
rev = rev + 1
Next i
End Sub
 
G

Gord Dibben

Don't copy the list of names.

In B1 enter =INDEX($A$1:$A$40,40-(ROW(A1)-1))

Double-click on B1 fill handle to copy down to B40


Gord Dibben MS Excel MVP
 

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

Similar Threads


Top