LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Copying values from one Workbook to Another

Hi,

I am trying to copy values from one workbook to another. I will be copying
many ranges.

The code below is my attempt at a simplified version. I got to the last
line where the vba code died.

Can someone please point out where I went wrong? Thank you.

Best regards,
Kevin


Sub GetData()

Dim wkbkSource As Workbook
Dim oSourceSheet As Object

Dim sSourceBook As String
Dim sSourceSheet As String

Dim oCurrentSheet As Object '\sets activesheet as oCurrentSheet

Set oCurrentSheet = ActiveSheet

sSourceBook = oCurrentSheet.Range("xsSWkBkName")
'\ "Source.xls" was successfully transferred to sSourceBook

sSourceSheet = oCurrentSheet.Range("xsSWkShtName")
'\ "SourceSheet" was successfully transferred to sSourceSheet

On Error Resume Next
Set wkbkSource = Workbooks(sSourceBook)
On Error GoTo 0
If wkbkSource Is Nothing Then
Set wkbkSource = Workbooks.Open(sSourceBook)
End If

Set oSourceSheet = wkbkSource.Worksheets(sSourceSheet)

'\ Step below fails
'\ I am trying to copy the values from the Source Sheet in the Source
Workbook
'\ to the Current Sheet.
'\ Run time error 438, Object doesn't support this property or method.

oCurrentSheet.Range("DestRange").Values =
oSourceSheet.Range("MySourceRange").Values


End Sub


 
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
formula for copying values from one workbook to another ClareNaish Excel Worksheet Functions 1 October 3rd 06 03:07 PM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
copying values form one workbook to other dreamer[_20_] Excel Programming 0 July 9th 04 10:57 AM


All times are GMT +1. The time now is 01:15 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"