View Single Post
  #6   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

I am not a programmer. I am smart enough to modify code for my own
uses and even that is limited. Have no training in code or how to
build it from scratch, etc. I have looked at the example and haven't
the slightest idea how to implement it. I'm guessing, though, that
when I call it with the click of my button a box will come up asking
me for coordinates and I'll have to type in something like
"sheet2!A3:AP3", correct? Will that overwrite what is there or insert
it above the current A3:AP3?

How would I predefine 3 or 4 options, and cause the prompt that comes
up to give me a choice of those?


Ah! In this case a turnkey solution is needed, then. If I correctly
understand your task then...

1. select the row[s] to move
2. click a menu/button to display a dialog that lets you select the
destination row on another sheet in the same workbook OR any open
workbook.
3. When you click OK on the dialog the selected row[s] are moved.

...is what you want the macro to do.

Sub MoveRows()
Dim rngSource As Range, rngTarget As Range
Set rngSource = Selection.EntireRow
Set rngTarget = Application.InputBox(Prompt:="Select the destination
row position", Title:="Move Rows", Type:=8)
rngSource.EntireRow.Cut rngTarget
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