Created
May 26, 2016 16:12
-
-
Save simonbromberg/b802fce556b56d0ba5f7a8143c42369e to your computer and use it in GitHub Desktop.
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
'a simple, (and pretty inefficient, but easy) macro to flip the values in a horizontal or vertical range. Saves a lot of time when you just want to swap two values or flip a list. | |
Sub flipRange() | |
' | |
' flipRange Macro | |
' | |
' | |
Dim i As Long | |
Dim num As Long | |
Dim newRange As Range | |
Dim rng As Range | |
Dim formulas() As String | |
i = 1 | |
num = Selection.Cells.count | |
ReDim formulas(1 To num) | |
For Each rng In Selection | |
formulas(i) = rng.Formula | |
i = i + 1 | |
Next rng | |
i = num | |
For Each rng In Selection | |
rng.Formula = formulas(i) | |
i = i - 1 | |
Next rng |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment