N1KO;490988 said:
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 E
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
Isn't the range you quote (A1:F1) a horizontal range, so shouldn't i
be flipping horizontally?
Anyway:
1. Worksheet formula solution: In A2 place this formula:
=INDEX($A$1:$F$1,COLUMNS($A$1:$F$1)+COLUMN($A$1:$F$1)-COLUMN())
and copy across to F2.
It's more complex than it needs to be for your example range whic
starts in column 1, but this formula will work for a range of any width
starting in any column, as long as the formula (a) refers the whol
range you want flipping in each of the 3 occasions it's used, and (b) i
in the same columns as the range to be flipped. (It can be used slightl
differently so that your result is anywhere in the sheet, for exampl
this flips your A1:F1 range to E41:J41 when placed in that range:
=INDEX($A$1:$F$1,COLUMNS($E$41:$J$41)+COLUMN($E$41:$J$41)-COLUMN())
2. Macro solution: This flips the single row of selected cells in situ
Be aware that it will replace any formulae wit
values:Sub blah() 'horizontal flip
If Selection.Areas.Count = 1 And Selection.Rows.Count = 1 Then '
check
xxx = Selection
yyy = xxx
For i = LBound(xxx, 2) To UBound(xxx, 2)
yyy(1, i) = xxx(1, UBound(xxx, 2) - i + 1)
Next i
Selection = yyy
End If
End Su