Young_Money
New Member
- Joined
- Jul 8, 2011
- Messages
- 23
Hi guys..
I currently have a userform that has buttons. Here is the code for one of the buttons. I want to be able to click the button and have my highlighted data copy and paste into "Sheet2". However, I am getting a run time error "1004"
Application defined or object defined error. Below is my code for that button. When I debug it, it says Set rngPaste = Sheets("Sheet2").Cells(i, 1) is wrong.
Sub CommandButton1_Click()
Dim rngCopy As Range
Dim rngPaste As Range
Dim i As Integer
Set rngCopy = Selection
Set rngPaste = Sheets("Sheet2").Cells(i, 1)
rngCopy.Copy rngPaste
End Sub
Would anybody be able to point out what is wrong please?
I currently have a userform that has buttons. Here is the code for one of the buttons. I want to be able to click the button and have my highlighted data copy and paste into "Sheet2". However, I am getting a run time error "1004"
Application defined or object defined error. Below is my code for that button. When I debug it, it says Set rngPaste = Sheets("Sheet2").Cells(i, 1) is wrong.
Sub CommandButton1_Click()
Dim rngCopy As Range
Dim rngPaste As Range
Dim i As Integer
Set rngCopy = Selection
Set rngPaste = Sheets("Sheet2").Cells(i, 1)
rngCopy.Copy rngPaste
End Sub
Would anybody be able to point out what is wrong please?