Hi all,
I currently have a working macro which I'd like to improve. Its only purpose is to flip the data for as many rows and columns the sheet has, leaving headers alone.
I mostly need to set the range in a better way (I know its current code can definitely be improved!).
Is there a better/easier code way to achieve the flip? (Please note I do NOT need the data to be sorted "A-Z", "Z-A" or any other sort Excel might have. I just need the data to be flipped).
Thanks for any help!
Sub Reverse_Flip()
Columns(1).Insert
Range("A2:A" & Cells(Rows.Count, "B").End(xlUp).Row).Formula = "=ROW(RC)-1"
Application.CutCopyMode = False
ActiveSheet.SORT.SortFields.Clear
ActiveSheet.SORT.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveSheet.SORT
.SetRange Range("A1:Z50000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns(1).Delete shift:=xlToRight
End Sub
Bookmarks