Copy then Paste at User Selected Cell

norts55

Board Regular
Joined
Jul 27, 2012
Messages
184
I am trying to write a macro that selects a named range of cells, copies them to the clipboard, asks the user to pick a cell for pasting and after the selection is made, then paste in the selected cell.

This may be redundant below but I will show the steps more in detail.

Step one: Select name range "_0_a_a_Combo_Box_Footer"
Step two: Copy name range "_0_a_a_Combo_Box_Footer" to Clipboard
Step three: A dialog box pops up asking the user to select a cell to paste the clipboard contents.
Step four: Paste contents of clipboard in selected cell.

I cannot figure out why this macro does not work. Any help would be greatly appreciated as I am very frustrated.
Thanks in Advance to anyone who is willing to help.

Just an FYI, the dialog portion of my code is copied from another thread. If whoever created that reads this, I say thank you.
Code:
Sub a_0_0_Paste_Footer()'
' a_0_0_Paste_Footer Macro
'


'
   
    Application.Goto Reference:="_0_a_a_Combo_Box_Footer"
    Selection.Copy
    Application.Wait Now + TimeSerial(0, 0, 1)
    Sheets("Takeoff").Select
    
Dim myRange As Range
    On Error Resume Next
    Set myRange = Application.InputBox(Prompt:="Select Cell to Paste Clipboard Contents", _
                                       Title:="Format Titles", Type:=8)
    On Error GoTo 0
  If myRange Is Nothing Then
        MsgBox "No selection made", vbCritical, "Input required"
        Exit Sub
    End If
        
    Selection.Insert Shift:=xlDown
    Application.CutCopyMode = False


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this:
Code:
Sub a_0_0_Paste_Footer()

Dim myRange As Range
Dim CopyRange As Range

Set CopyRange = Range("_0_a_a_Combo_Box_Footer")


On Error Resume Next
Set myRange = Application.InputBox(Prompt:="Select Cell to Paste Clipboard Contents", Title:="Format Titles", Type:=8)

If myRange Is Nothing Then
    MsgBox "No selection made", vbCritical, "Input required"
    Exit Sub
End If

CopyRange.Copy Destination:=myRange

End Sub
 
Upvote 0
Thank you Max1616 for the response. This works very well. However, I realize that I did not describe the last step clear enough. instead of using “paste” where the cells are over written, I need this to insert and shift cells down. Is that possible? The reason I need this is because I have filled in cells below where I am pasting this and I cannot have that information over written.
 
Upvote 0
Give this a try:
Code:
Sub a_0_0_Paste_Footer()

Dim myRange As Range
Dim CopyRange As Range

Set CopyRange = Range("_0_a_a_Combo_Box_Footer")


On Error Resume Next
Set myRange = Application.InputBox(Prompt:="Select Cell to Paste Clipboard Contents", Title:="Format Titles", Type:=8)

If myRange Is Nothing Then
    MsgBox "No selection made", vbCritical, "Input required"
    Exit Sub
End If

CopyRange.Copy

myRange.Insert Shift:=xlDown

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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