View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
magmike[_2_] magmike[_2_] is offline
external usenet poster
 
Posts: 35
Default DREAM FEATU A macro that moves a row but asks me where to move it

When I do t this way, it ends up deleting the new row. Any thoughts?

Dim rngSource As Range, rngTarget As Range
Set rngSource = Selection.EntireRow
rngSource.Copy
Set rngTarget = Application.InputBox(Prompt:=sPrompt, Title:="Move Rows", Type:=8)

If rngTarget Is Nothing Then Exit Sub
If Not rngTarget Is Nothing Then rngSource.Cut rngTarget
rngSource.EntireRow.Delete

On Thursday, December 19, 2013 10:02:15 AM UTC-6, GS wrote:
I think I solved my own question. I changed the line to: rngSource.EntireRow.Delete xlUp Yes, that's what I would do. Note, though, there is no need to specify the shift direction since you use the default. Sorry I wasn't clear on your explanation of the source row issue... Sub CopySelection() Dim rngSource As Range, rngTarget As Range, lRow& Const sPrompt$ = "Select the destination row position" lRow = Selection.Row Set rngSource = ActiveSheet.Range("A" & lRow & ":AP" & lRow) Set rngTarget = Application..InputBox(Prompt:=sPrompt, _ Title:="Move Rows", Type:=8) If rngTarget Is Nothing Then Exit Sub With rngTarget.Resize(1, rngSource.Columns.Count) .Insert: .Offset(-1).Value = rngSource.Value End With rngSource.EntireRow.Delete End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com