View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
SAMURA SAMURA is offline
external usenet poster
 
Posts: 8
Default Need a macro to copy a range in one workbook and paste into another workbook

Hi.
It may be late, I fixed that macro.
This macro does not receive the error.
The macro opens the book "ITHD Monthly Calculator for reports V5.xls",
and pastes from "ITHD Reports.xls" to the book, and saves the book,
and closes the book.


Sub ITHDdocID()

Dim rng As Range
Dim pastedBook As Workbook

Windows("ITHD Reports.xls").Activate

Worksheets("ITHD").Range("A6").Select

'selected from ITHD!A6 to the end
Set rng = Range(Selection, Selection.End(xlDown))
rng.Select
rng.Copy

'opened the book "ITHD Monthly Calculator for reports V5.xls"
Set pastedBook = Workbooks.Open("ITHD Monthly Calculator for reports
V5.xls")

'pasted to Time!A3
pastedBook.Worksheets("Time").Range("A3").PasteSpe cial xlPasteValues

'saved the book "ITHD Monthly Calculator for reports V5.xls"
pastedBook.Save

'closed the book "ITHD Monthly Calculator for reports V5.xls"
pastedBook.Close
Set pastedBook = Nothing

End Sub


--
Samura


"Paul" wrote in message
om...
Thanks for you help Samura,
But I receive an error on running the code.
"Subscript out of range"
on the line :"Windows("ITHD Monthly Calculator for reports

V5.xls").Activate"

But anyway I have found a solution.

So Once again Thank you very much