lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I want to learn how to copy and paste a cell in vba. First, I thought it is as easy as
Cells(1,1).copy
cells(2,2).paste
That would copy cells(1,1) and paste it into cells(2,2) but that did not work. It leads me to a question on why I have cell.paste function?
So I went to watch a video and in that video the author did this
Range("A1").copy Range("C1)
That would copy A1 to C1
So I tried almost the same thing but did not work, please see the code below
I want to learn how to copy and paste a cell in vba. First, I thought it is as easy as
Cells(1,1).copy
cells(2,2).paste
That would copy cells(1,1) and paste it into cells(2,2) but that did not work. It leads me to a question on why I have cell.paste function?
So I went to watch a video and in that video the author did this
Range("A1").copy Range("C1)
That would copy A1 to C1
So I tried almost the same thing but did not work, please see the code below
Code:
Sub copypaste()
Dim x As Integer
Dim y As Integer
Dim n As Integer
Dim m As Integer
x = InputBox("first cell row")
y = InputBox("first cell col")
n = InputBox("second cell row")
m = InputBox("second cell col")
ThisWorkbook.ActiveSheet.Cells(x, y).Copy ThisWorkbook.ActiveSheet.Cells(n, m)
End Sub