How to paste to the next empty orw

Joined
Dec 3, 2008
Messages
3
Reaction score
0
Hi I have written the following code which is supposed to allow the user to select some data from one sheet and then the code is supposed to paste into another sheet. The code works but the pasted data doesn't go into the first blank row as it should, what am I doing wrong?

Private Sub CommandButton2_Click()

Call GetRange
End Sub

Sub GetRange()
Dim oRangeSelected As Range
Dim NextRow 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"))
Cells(NextRow + 1, 1) = ActiveSheet.Paste

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