View Single Post
  #2   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.
I fixed your macro. Is it a macro what you would like to write?


Sub ITHDdocID()

Dim rng As Range

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

Windows("ITHD Monthly Calculator for reports V5.xls").Activate

'pasted to Time!A3
Worksheets("Time").Range("A3").PasteSpecial xlPasteValues

End Sub


--
Samura


"Paul" wrote in message
om...
Hi all,
I'm experienced in excel, but not very good with Macros.
I am trying to write a macro to copy from 1 workbook into another.
Using Window 2K SP4, and MS Office 2k SR1
So far I have only this using the Macro Recorder:
Sub ITHDdocID()
'
' ITHDdocID Macro
' Macro recorded 25/06/2004 by husky101
'

'
Windows("ITHD Reports.xls").Activate
Range("A6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("ITHD Monthly Calculator for reports V5.xls").Activate
ActiveSheet.Paste
Range("B3").Select
End Sub

When I run this macro I receive a 'Subscript out of range error', on
line 5 the destination wkbk.
I need to copy an unkown range down from ITHD!A6 from wkbk (ITHD
Reports.xls)
and paste into wkbk2 (ITHD Monthly Calculator for reports V5.xls) into
sheet Time!A3