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

Sweet. Thank you! I'm curious if it is possible to do the followong:

1. Just move cells A:AP (not the entire row)
2. Just move the values without formatting
3. Move the row I select as destination down instead of overwriting
4. Delete the empty space caused by the move



Using 'Insert' can shift the destination cells down and put the source
values in the resulting space. (No need to delete)

This does nothing to the source cells...

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
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