SELECTION INFORMATION NEEDED PLEASE HELP

K

Kaan Demirtas

Hello,

I need to get the information about the selection I have made with my mouse.

What I am trying to do is converting rows or columns from upside-down to
downside-up for more brief explanation 5 rows will change as
row 1 ===> will replace with row 5
row 2 ===> will replace with row 4
row 3 ===> will replace with row 3
row 4 ===> will replace with row 2
row 5 ===> will replace with row 1

is there any simpler solution for that???

and help will be appreciated.
 
B

Bernie Deitrick

Kaan,

Select your cells, and run the macro below.

HTH,
Bernie
Excel MVP

Sub InvertRange()
Dim myRange As Range
Set myRange = Selection

Application.ScreenUpdating = False
myRange.Cells(1).EntireColumn.Insert
Set myRange = myRange.Offset(0, -1).Resize( _
myRange.Rows.Count, myRange.Columns.Count + 1)
myRange.Select
With myRange.Columns.Item(1)
.Formula = "=ROW()"
.Value = .Value
End With
myRange.Sort myRange.Columns(1), _
xlDescending, , , , , , _
xlNo, , , xlSortColumns
myRange(1).EntireColumn.Delete
myRange(1).Select
Application.ScreenUpdating = True

End Sub
 
T

Tom Ogilvy

I would go to the next available column and put in the numbers
1
2
3
4
5

Then I would select all the data and sort (Data=>Sort) on the column
Descending.

then remove the dummy numbers.
 

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