Advertisement
Guest User

Untitled

a guest
May 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. '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.
  2.  
  3. Sub flipRange()
  4. '
  5. ' flipRange Macro
  6. '
  7.  
  8. '
  9. Dim i As Long
  10. Dim num As Long
  11. Dim newRange As Range
  12. Dim rng As Range
  13. Dim formulas() As String
  14.  
  15. i = 1
  16. num = Selection.Cells.count
  17. ReDim formulas(1 To num)
  18.  
  19. For Each rng In Selection
  20. formulas(i) = rng.Formula
  21. i = i + 1
  22. Next rng
  23. i = num
  24.  
  25. For Each rng In Selection
  26. rng.Formula = formulas(i)
  27. i = i - 1
  28. Next rng
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement