How to Copy from one sheet and paste into another

Joined
Dec 3, 2008
Messages
3
Reaction score
0
Hi folks, I am trying to write some VB code that allows the user to select a range via an input box, then copy that range and paste it into a different worksheet.
The code I have written allows the selection OK, but I can't get it to paste into the correct position in the other worksheet. What is supposed to happen is the code finds the next blank row and then pastes the selection underneath. It the moment it pastes into whatever cell was last selected.
Can anybody help?

Sub GetRange()
Dim oRangeSelected As Range
Dim NextRow As Long
Dim LastRow As Long
On Error Resume Next
Sheets("Data").Activate
Set oRangeSelected = Application.InputBox("Please select a range of cells!", _
"Select A Range", Selection.Address, , , , , 8)
If oRangeSelected Is Nothing Then
MsgBox "It appears as if you pressed cancel!"
Else

Range(oRangeSelected).Select
Selection.Copy
Sheets("Sampled Data Summary").Activate
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
With Sheets("Sampled Data Summary")
Range("A3").Select
Cells(3, 1) = ActiveSheet.Paste

End With
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top