ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Cell Using Macro (https://www.excelbanter.com/excel-programming/296245-copying-cell-using-macro.html)

Mpho[_3_]

Copying Cell Using Macro
 
Heloo! There
I'd like to create a macro that copies the cell range from one workbook to anothe

I have two workbooks, namely Book1 and Book2, When I open Book2, It must copy the cell range e.g A1:B1
from Book1 and place them in the same range

Thank
Mpho

Melanie Breden

Copying Cell Using Macro
 
I'd like to create a macro that copies the cell range from one workbook to another

I have two workbooks, namely Book1 and Book2, When I open Book2, It must copy the cell range e.g A1:B10
from Book1 and place them in the same range.


try this in ThisWorkbook from Book2:

Private Sub Workbook_Open()
Dim wbk As Workbook

' examine whether Book1 is open
On Error Resume Next
Set wbk = Workbooks("Book1")
If Err Then Exit Sub

Me.Worksheets("Sheet1").Range("A1:B10").Value = _
wbk.Worksheets("Sheet1").Range("A1:B10").Value
End Sub

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)



All times are GMT +1. The time now is 11:58 PM.

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