Macro trouble
Hey all this is my first time here, so I hope I can get some help from all you office Guru's.
Im working with a spreadsheet in Excel 2010 and have been tasked to create 3 macros. 1 macro to delete an entire row at once with a keystroke, which is done. And also 2 macros to move a row of data up 1 line or down 1 line and shift the rows around it, without losing any data.
I was able to create a macro to move a row of data up 1 lines and have the line above it shift down, basically swapping the two lines. Here's my "Move Line Up" code:
Sub Moveup()
'
' Moveup Macro
'
' Keyboard Shortcut: Ctrl+u
'
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Cut
ActiveCell.Offset(-1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
End Sub
This method does work for moving a line. HOWEVER when I try creating one to move a row DOWN, all that happens is the selection box moves down, not the data itself.
Sub MoveDown()
'
' MoveDown Macro
'
' Keyboard Shortcut: Ctrl+a
'
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Cut
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
End Sub
BOTTOM LINE: Does anyone have any ideas here? I need to move a single row of data down 1 line and have the row below it move up. HELP!
|