Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Copying to another workbook

xl2003

I am trying to copy data from one workbook to another. What I have so for is
below. VBA does not like Set Wkbk = Workbooks("12Sept05.xls")
and I know I am going to have a problem with copyToRng in that it does not
refer to the workbook or worksheet, just the range.
(Stolen code is just never complete!)

Any help would be greatly appreciated.
Ta,
Martin

Public Sub StartCopy()
Dim wks As Worksheet
Dim Wkbk As Workbooks
Dim Wkbk2 As Workbooks
Dim copyToRng As Range

Set Wkbk = Workbooks("12Sept05.xls")
Set Wkbk2 = Workbooks("TheBigStatTable.xls")

For Each wks In Wkbk
If Left(wks.Name, 1) = "R" Then 'each wkbk has 10 sheets and
I want to copy the data from each putting it at the bottom of the range in
TheBigStatTable
With wks
Set copyToRng = .Range("C12").End(xlDown).Offset(1, 0)
.Range("E3").Copy copyToRng


End With
End If
Next
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Copying to another workbook

Hi Martin

You need to change the definition of your workbook variables to:

Dim Wkbk As Workbook
Dim Wkbk2 As Workbook

Then to start your loop:
For Each wks In Wkbk.worksheets
'code
next wks

I hope this gets you started
Regards
Rowan


Martin Wheeler wrote:
xl2003

I am trying to copy data from one workbook to another. What I have so for is
below. VBA does not like Set Wkbk = Workbooks("12Sept05.xls")
and I know I am going to have a problem with copyToRng in that it does not
refer to the workbook or worksheet, just the range.
(Stolen code is just never complete!)

Any help would be greatly appreciated.
Ta,
Martin

Public Sub StartCopy()
Dim wks As Worksheet
Dim Wkbk As Workbooks
Dim Wkbk2 As Workbooks
Dim copyToRng As Range

Set Wkbk = Workbooks("12Sept05.xls")
Set Wkbk2 = Workbooks("TheBigStatTable.xls")

For Each wks In Wkbk
If Left(wks.Name, 1) = "R" Then 'each wkbk has 10 sheets and
I want to copy the data from each putting it at the bottom of the range in
TheBigStatTable
With wks
Set copyToRng = .Range("C12").End(xlDown).Offset(1, 0)
.Range("E3").Copy copyToRng


End With
End If
Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Copying to another workbook

Hi Rowan,
Thanks thats a great start.
Ta,
Martin


"Rowan" wrote in message
...
Hi Martin

You need to change the definition of your workbook variables to:

Dim Wkbk As Workbook
Dim Wkbk2 As Workbook

Then to start your loop:
For Each wks In Wkbk.worksheets
'code
next wks

I hope this gets you started
Regards
Rowan


Martin Wheeler wrote:
xl2003

I am trying to copy data from one workbook to another. What I have so for
is below. VBA does not like Set Wkbk = Workbooks("12Sept05.xls")
and I know I am going to have a problem with copyToRng in that it does
not refer to the workbook or worksheet, just the range.
(Stolen code is just never complete!)

Any help would be greatly appreciated.
Ta,
Martin

Public Sub StartCopy()
Dim wks As Worksheet
Dim Wkbk As Workbooks
Dim Wkbk2 As Workbooks
Dim copyToRng As Range

Set Wkbk = Workbooks("12Sept05.xls")
Set Wkbk2 = Workbooks("TheBigStatTable.xls")

For Each wks In Wkbk
If Left(wks.Name, 1) = "R" Then 'each wkbk has 10 sheets
and I want to copy the data from each putting it at the bottom of the
range in TheBigStatTable
With wks
Set copyToRng = .Range("C12").End(xlDown).Offset(1, 0)
.Range("E3").Copy copyToRng


End With
End If
Next
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying workbook formating to a differnent workbook Roger Excel Worksheet Functions 0 October 30th 09 05:27 PM
Copying Formulas from Workbook to Workbook Rupert[_2_] Excel Discussion (Misc queries) 3 June 4th 07 03:44 PM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
Copying charts from workbook to workbook Geoff C Charts and Charting in Excel 2 March 13th 05 05:04 AM
Copying workbook contents to another workbook Josh Sale Excel Programming 3 November 23rd 03 10:57 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"