Named Range selection and copy in a new Cell

Sumeluar

Active Member
Joined
Jun 21, 2006
Messages
278
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
Good day!

I have a simple macro that it copies a named range with entire rows and pastes it right above where the named range is, I would like to modify it to ask in which new cell I want to insert it. Is probably easy but my limited VBA skills lead me to ask for help.

Sub Insert_New_Task()
Range("NewTask").Select
With Selection.EntireRow.Copy
'Maybe here - Popup to to select the cell where to insert the selected range
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.FillDown
End With
End Sub

Regards!

Sumeluar
 
Fiddling a bit more I added a new line of code:

Sub Insert_New_Task()
Range("NewTask").Select
With Selection.EntireRow.Copy
Range("A210").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove '.PasteSpecial xlPasteValues
Selection.FillDown
End With
End Sub

I'm getting closer as the range is copied on row 210, I hope someone guides me through the rest.

Regards!

Sumeluar
 
Upvote 0
This should get you going:
VBA Code:
Sub Insert_New_Task()
    Dim destination As Range
    On Error Resume Next
    Set destination = Application.InputBox("Please select the destination for the paste", "Destination", "A210", , , , , 8)
    On Error GoTo 0
    If Not destination Is Nothing Then
        Range("NewTask").Select
        With Selection.EntireRow.Copy
            destination.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove    '.PasteSpecial xlPasteValues
            Selection.FillDown
        End With
    End If
End Sub
 
Upvote 0
Solution
jkpieterse - Thank you for the prompt and accurate reply, doing what I was looking for.

Regards!

Sumeluar
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top