It's still not working.
This time there's no error message but the data gets pasted anyway, even though Cancel is pressed twice.
It should actually Exit after the first Cancel.
Option Explicit
Sub My_Range_Sel()
Dim Range1 As Range, Range2 As Range 'Important
Dim X As Variant, Y As Variant, z As Variant, c As Long
Dim xTitleId As String
xTitleId = "Selection"
Set Range1 = Worksheets("MySheet").Range(Cells(11, 3), Cells(15, 5))
' Set Range1 = Application.InputBox("Source Range", xTitleId, Range1.Address, Type:=8)
On Error Resume Next
Set Range1 = Application.InputBox("Source Range", "Selection", "$C$11:$E$15", Type:=8)
On Error GoTo 0
If Range1 Is Nothing Then Exit Sub ' user canceled
ReDim z(1 To WorksheetFunction.CountA(Range1)) 'Size of array
Cells(ActiveCell.Row, ActiveCell.Column).Activate
Set Range2 = Cells(ActiveCell.Row, ActiveCell.Column)
' Set Range2 = Application.InputBox("Paste To", xTitleId, Range2.Address, Type:=8)
On Error Resume Next
Set Range2 = Application.InputBox("Paste To", "Selection", Range2.Address, Type:=8)
On Error GoTo 0
If Range2 Is Nothing Then Exit Sub ' user canceled
X = Range1.Value
If Range1.Count > 1 Then
c = 1
For Each Y In X
If Y <> "" Then z(c) = "Copy of - " & Y: c = c + 1
Next Y
With Range2
.Resize(UBound(z), 1).Value = Application.Transpose(z)
.Parent.Activate
.Resize(UBound(z), 1).Select
End With
End If
End Sub
Bookmarks