Copy cells selected by user and paste to location that they select

mamun_ges

Board Regular
Joined
Jul 21, 2016
Messages
52
Hi,

I have found help from the Thread
Copy cells selected by user and paste to location that they select
the Code is
Code:
Sub YesMacro()
    On Error Resume Next
    Set Ret = Application.InputBox(Prompt:="Please select a range where you want to paste", Type:=8)
    On Error GoTo 0
    If Not Ret Is Nothing Then
        Selection.Copy
        Ret.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
    End If
End Sub
but the problem of mine is I want to copy data to another sheet in same workbook. Then what will be the code is?

Thanks in Advance
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello Mamun-ges,

Perhaps the following may help:-

Code:
Sub Test()

   Dim rng As Range
   
On Error Resume Next
Set rng = Application.InputBox(Prompt:="Select range to be moved.", Title:="Select Ranges", Type:=8)

Application.ScreenUpdating = False

   If Not rng Is Nothing Then
   rng.Copy
   Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues
   End If
   
Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Thank you for your support vcoolio

Actually I want to paste data in sheet two which I will select and this is changeable, It may be B column or C column or other. So it will be helpful for me if I create a active x Control to update, then a popup
like that where I will Input in which column data will be paste, the data will always paste in sheet 2 but in different columns.

Can it done?

Thank You.
 
Upvote 0
Hello Mamun_ges,

.....the data will always paste in sheet 2 but in different columns.

Your image link doesn't work, however try the amended code below, assigned to a button:-

Code:
Sub Test()

    Dim rng As Range
    Dim cSearch As String

Application.ScreenUpdating = False

Set rng = Application.InputBox(Prompt:="Select range to be moved.", Title:="Select Ranges", Type:=8)
cSearch = InputBox("Please enter a column letter.")
If cSearch = vbNullString Then Exit Sub

   If Not rng Is Nothing Then
   rng.Copy Sheet2.Range(cSearch & Rows.Count).End(3)(2)
   End If
   
Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

With the code, an input box will appear asking you to select a range to copy then another input box will appear asking you to input the column letter to which you wish to transfer the range (in sheet2).

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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