Copying Cell Using Macro

G

Guest

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
 
M

Melanie Breden

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top