ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help excel (https://www.excelbanter.com/excel-programming/345458-help-excel.html)

Ivica Lopar

help excel
 
how can I copy specific range of cells from one workbook to another



Leith Ross[_264_]

help excel
 

Hello Ivica Lopar,

Susbstitute your workbook names and ranges in place of the ones in the
example. This example assumes 2 workbooks are open: Book1.xls and
Book2.xls. The macro copies the range A1:A5 from Book1.xls, Sheet1 to
Book2.xls, Sheet1 range B1:B5.


Code:
--------------------
Public Sub CopyRanges()

Sub CopyRange()

Dim dstRng As Excel.Range
Dim srcRng As Excel.Range

Set dstRng = Workbooks("Book2.xls").Worksheets("Sheet2").Range( "B1:B5")
Set srcRng = Workbooks("Book1.xls").Worksheets("Sheet1").Range( "A1:A5")

srcRng.Copy dstRng.Value

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=484597


Tom Ogilvy

help excel
 
Dim sh1 as Worksheet, sh2 as Worksheet
set sh1 = Workbooks("Book1.xls").WorkSheets("Sheet1")
set sh2 = Workbooks("Book2.xls").Worksheets("Sheet3"

sh1.Range("a1:B10").copy Destination:=sh2.Range("F9")

--
Regards,
Tom Ogilvy

"Ivica Lopar" wrote in message
...
how can I copy specific range of cells from one workbook to another






All times are GMT +1. The time now is 10:25 AM.

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