ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy/paste (https://www.excelbanter.com/excel-programming/293510-copy-paste.html)

Lee

copy/paste
 
In macro, the following will do copy and paste, but what
is I need the index 7 and 14 below to be a variable?

Range("C7:D14").Select
Selection.Copy
Range("F2").Select
ActiveSheet.Paste


Bob Kilmer[_2_]

copy/paste
 
Dim m As Long
Dim n As Long

Range("C" & CStr(m) & ":D" & CStr(n)).Select
Selection.Copy
Range("F2").Select
ActiveSheet.Paste


"Lee" wrote in message
...
In macro, the following will do copy and paste, but what
is I need the index 7 and 14 below to be a variable?

Range("C7:D14").Select
Selection.Copy
Range("F2").Select
ActiveSheet.Paste




Bob Kilmer[_2_]

copy/paste
 
Dim r1 As Long, c1 As Long, r2 As Long, c2 As Long
r1 = 7: c1 = 3: r2 = 14: c2 = 4
Range(Cells(r1, c1), Cells(r2, c2)).Copy Range("F2")

"Lee" wrote in message
...
In macro, the following will do copy and paste, but what
is I need the index 7 and 14 below to be a variable?

Range("C7:D14").Select
Selection.Copy
Range("F2").Select
ActiveSheet.Paste





All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com