Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Move row to another location on sheet

Hi all. Is there a way to move a row of data to another location on
the sheet? I'd start with the active cell (row), and when the code
executes be prompted with "what row would you like to move the current
row to?". Then obviuosly move, for example, row 32 up to row 5,
moving all other rows down one.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Move row to another location on sheet

Steve wrote on 5/2/2011 :
Hi all. Is there a way to move a row of data to another location on
the sheet? I'd start with the active cell (row), and when the code
executes be prompted with "what row would you like to move the current
row to?". Then obviuosly move, for example, row 32 up to row 5,
moving all other rows down one.

Thanks!


Is there some reason you can't use CutInsert Cut Cells?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default Move row to another location on sheet

Option Explicit
Sub move_row()
Dim sourcerow, targetrow As Range
Set sourcerow = Application.InputBox(prompt:= _
"Select Any Cell in Row to Move", Type:=8)
Set targetrow = Application.InputBox(prompt:= _
"Select Any Cell in Row for Insertion", Type:=8)
sourcerow.entirerow.Cut
targetrow.Insert shift:=xlDown
Application.CutCopyMode = False
End Sub


Gord Dibben MS Excel MVP

On Mon, 2 May 2011 12:39:31 -0700 (PDT), Steve
wrote:

Hi all. Is there a way to move a row of data to another location on
the sheet? I'd start with the active cell (row), and when the code
executes be prompted with "what row would you like to move the current
row to?". Then obviuosly move, for example, row 32 up to row 5,
moving all other rows down one.

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Move row to another location on sheet

Thank you Gord! Is there a way to add some error handling if the user
select cancel on either inputbox?

Thanks again!

On May 2, 6:08*pm, Gord Dibben wrote:
Option Explicit
Sub move_row()
* * Dim sourcerow, targetrow As Range
* * Set sourcerow = Application.InputBox(prompt:= _
* * * * * * "Select Any Cell in Row to Move", Type:=8)
* * Set targetrow = Application.InputBox(prompt:= _
* * * * * * "Select Any Cell in Row for Insertion", Type:=8)
* * sourcerow.entirerow.Cut
* * targetrow.Insert shift:=xlDown
* * Application.CutCopyMode = False
End Sub

Gord Dibben * * MS Excel MVP

On Mon, 2 May 2011 12:39:31 -0700 (PDT), Steve
wrote:



Hi all. *Is there a way to move a row of data to another location on
the sheet? *I'd start with the active cell (row), and when the code
executes be prompted with "what row would you like to move the current
row to?". *Then obviuosly move, for example, row 32 up to row 5,
moving all other rows down one.


Thanks!- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Move row to another location on sheet

Gord,

I added this after each inputbox group of code:
If sourcerow Is Nothing Then
Exit Sub
End If

Not sure if Exit Sub is a preferred method of error handling, but it
worked!

Thanks again for your help!

On May 2, 9:10*pm, Steve wrote:
Thank you Gord! *Is there a way to add some error handling if the user
select cancel on either inputbox?

Thanks again!

On May 2, 6:08*pm, Gord Dibben wrote:



Option Explicit
Sub move_row()
* * Dim sourcerow, targetrow As Range
* * Set sourcerow = Application.InputBox(prompt:= _
* * * * * * "Select Any Cell in Row to Move", Type:=8)
* * Set targetrow = Application.InputBox(prompt:= _
* * * * * * "Select Any Cell in Row for Insertion", Type:=8)
* * sourcerow.entirerow.Cut
* * targetrow.Insert shift:=xlDown
* * Application.CutCopyMode = False
End Sub


Gord Dibben * * MS Excel MVP


On Mon, 2 May 2011 12:39:31 -0700 (PDT), Steve
wrote:


Hi all. *Is there a way to move a row of data to another location on
the sheet? *I'd start with the active cell (row), and when the code
executes be prompted with "what row would you like to move the current
row to?". *Then obviuosly move, for example, row 32 up to row 5,
moving all other rows down one.


Thanks!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




Reply
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
Maintaining hyperlinks when I move Excel files to another location diestro Excel Discussion (Misc queries) 1 December 15th 09 07:01 PM
Why objects inserted in excel move to different location in print Marwa Excel Discussion (Misc queries) 1 June 16th 09 02:27 PM
Move active cell to same location on each worksheet BeanoKid Excel Discussion (Misc queries) 3 April 15th 08 11:29 PM
Functions that will move info to a different location in column Bill R Excel Worksheet Functions 8 December 10th 07 11:36 PM
How to move location of chart within a worksheet? [email protected] Excel Discussion (Misc queries) 1 May 17th 05 11:38 PM


All times are GMT +1. The time now is 10:40 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"