View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Melanie Breden Melanie Breden is offline
external usenet poster
 
Posts: 88
Default 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)