Created
June 15, 2020 10:24
-
-
Save 0xLeon/5f69a063e6540c62433d5149220849ba to your computer and use it in GitHub Desktop.
Excel - Flip Rows / Columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub FlipRows() | |
Dim vTop As Variant | |
Dim vEnd As Variant | |
Dim iStart As Integer | |
Dim iEnd As Integer | |
Application.ScreenUpdating = False | |
Application.Calculation = xlCalculationManual | |
iStart = 1 | |
iEnd = Selection.Rows.Count | |
Do While iStart < iEnd | |
vTop = Selection.Rows(iStart) | |
vEnd = Selection.Rows(iEnd) | |
Selection.Rows(iEnd) = vTop | |
Selection.Rows(iStart) = vEnd | |
iStart = iStart + 1 | |
iEnd = iEnd - 1 | |
Loop | |
Application.Calculation = xlCalculationAutomatic | |
Application.ScreenUpdating = True | |
End Sub | |
Sub FlipColumns() | |
Dim vTop As Variant | |
Dim vEnd As Variant | |
Dim iStart As Integer | |
Dim iEnd As Integer | |
Application.ScreenUpdating = False | |
Application.Calculation = xlCalculationManual | |
iStart = 1 | |
iEnd = Selection.Rows.Count | |
Do While iStart < iEnd | |
vTop = Selection.Columns(iStart) | |
vEnd = Selection.Columns(iEnd) | |
Selection.Rows(iEnd) = vTop | |
Selection.Rows(iStart) = vEnd | |
iStart = iStart + 1 | |
iEnd = iEnd - 1 | |
Loop | |
Application.Calculation = xlCalculationAutomatic | |
Application.ScreenUpdating = True | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment