sdfjh87687
New Member
Hi
I'm excel beginner and not often user. I googled some easy macro, which easy and effectively provides me to move up down rows in already filled sheet and also columns left right.
I store all my handy macros in here in my windows 7: C:\Users\a\AppData\Roaming\Microsoft\AddIns\MyAddins.xlam
I was adding new macro as usuall. Insert > Module > paste code. save.
Then I went into ribbon customizations, but excel didn't offer me my macro. There were just all old ones.
Here is code for problematic new macro:
Thank you for any help !
I'm excel beginner and not often user. I googled some easy macro, which easy and effectively provides me to move up down rows in already filled sheet and also columns left right.
I store all my handy macros in here in my windows 7: C:\Users\a\AppData\Roaming\Microsoft\AddIns\MyAddins.xlam
I was adding new macro as usuall. Insert > Module > paste code. save.
Then I went into ribbon customizations, but excel didn't offer me my macro. There were just all old ones.
Here is code for problematic new macro:
Code:
Sub MoveRowsOrColumns(direction As String)
Dim rOriginalSelection As Range
Select Case direction
Case "up", "down"
Set rOriginalSelection = Selection.EntireRow
Case "left", "right"
Set rOriginalSelection = Selection.EntireColumn
Case Else
Debug.Assert False
End Select
With rOriginalSelection
.Select
.Cut
Select Case direction
Case "up"
.Offset(-1, 0).Select
Case "down"
.Offset(rOriginalSelection.Rows.Count + 1, 0).Select
Case "left"
.Offset(0, -1).Select
Case "right"
.Offset(0, rOriginalSelection.Columns.Count + 1).Select
End Select
End With
Selection.Insert
rOriginalSelection.Select
End Sub
Thank you for any help !