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
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