Flipping Data

N

N1KO

Hi,

Is there any way of flipping data vertically.

For example
I have data in cells A1, B1, C1, D1, E1, F1.

I want the data to be reversed. So A1 goes to F1, F1 to A1 B1 to E1 E1 to B1
etc. I need this to be done on any number of cells.

Either in macro code or cell formulae.

Thanks in advance

Niko
 
N

Newbie

...sorry misread...
adjacent column, insert 1 to 6 then sort by adjacent column Z to A
 
N

N1KO

Hi,

Yes technically it is being flipped horizontally sorry.

Thanks for the help I'll check them out as soon as i can.

Niko
 
R

Rick Rothstein

Here is another one you can try...

Sub FlipRow()
Dim X As Long, StartCol As Long, LastCol As Long, _
LastRow As Long, DataRow As Long
StartCol = 1
DataRow = 3
With ActiveSheet
LastRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious).Row
LastCol = Rows(DataRow).Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
For X = StartCol To LastCol
.Cells(DataRow, X).Copy .Cells(LastRow + 1, _
StartCol + LastCol - X)
Next
.Range(.Cells(LastRow + 1, StartCol), .Cells(LastRow + 1, LastCol)).Copy
..Cells(DataRow, StartCol)
.Range(.Cells(LastRow + 1, StartCol), .Cells(LastRow + 1,
LastCol)).Clear
End With
End Sub

Change the StartCol and DataRow as appropriate. If you want to do this for
more than one row, then create an outer For..Next loop after the LastRow
assignment statement and before the End With statement using DataRow as the
loop counter variable.
 

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