Guest User

zle makro

a guest
Sep 12th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub SwapSelectedCells_RYCHLE()
  2.  
  3.     If Selection.Areas.Count <> 2 Then Exit Sub
  4.  
  5.     Set range1 = Selection.Areas(1)
  6.     Set range2 = Selection.Areas(2)
  7.  
  8.     If range1.Rows.Count <> range2.Rows.Count Or _
  9.         range1.Columns.Count <> range2.Columns.Count Then Exit Sub
  10.  
  11.     range1Address = range1.Address
  12.     range1.Cut
  13.     range2.Insert Shift:=xlShiftToRight
  14.     Range(range1Address).Delete Shift:=xlToLeft
  15.  
  16.     range2Address = range2.Address
  17.     range2.Cut
  18.     Range(range1Address).Insert Shift:=xlShiftToRight
  19.     Range(range2Address).Delete Shift:=xlToLeft
  20.  
  21. End Sub
Advertisement
Add Comment
Please, Sign In to add comment