LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB code for Moving Rows up and down

Hi, I'm not trained in VB so may be missing something but this seems tider
because it doesn't change the user's selection and has less lines. Also it
checks for top row.

Sub MoveDown()

Range(ActiveCell.Row + 1 & ":" & ActiveCell.Row + 1).Cut 'Cut row below
ActiveCell.EntireRow.Insert Shift:=xlDown 'Paste
ActiveCell.Offset(1, 0).Select 'Move down to it

End Sub


Sub MoveUp()

If ActiveCell.Row 1 Then
Range(ActiveCell.Row & ":" & ActiveCell.Row).Cut 'Cut active row
ActiveCell.Offset(-1, 0).Select 'Move up a row
ActiveCell.EntireRow.Insert Shift:=xlDown 'Paste
End If

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving data from multiple rows to single rows Pete Excel Worksheet Functions 5 February 16th 08 01:51 PM
CODE 4 MOVING WITHIN A RANGE-TAB FARAZ QURESHI Excel Discussion (Misc queries) 0 December 5th 07 10:23 AM
Moving Code [email protected] Excel Programming 1 September 25th 04 05:58 PM
Code for moving cursor one cell to the right Kate Excel Programming 0 August 25th 04 08:54 PM
Code for moving textbox Phil Perry Excel Programming 2 July 9th 03 03:49 PM


All times are GMT +1. The time now is 03:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"