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


Hi Excel Gurus.

I have bought so many VBA books but can't find the solution.

What I need to do is export or import (whatever is best.)
a range from an open work book to a closed workbook.

Range a1 to I55

how can I do this?

Please give us some ideas and I will see if I can get my money out of
these books.

thx


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=387059

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Exporting to a closed workbook

You can Import from a closed wbk by using
DataGetExternalData

I don't think you can Export from an open wbk to a "closed" wbk.
but, you can do it with vba in the blink of an eye:

Sub Export()
Dim sFile as String
Dim rSource as Range
Dim rDest as Range

Set rSource =ThisWorkbook.ActiveSheet.Range("A1:I55")

sFile = ThisWorkbook.Path & "\MyFile.xls" 'Adjust as needed
Workbooks.Open sFile
Set rDest = ActiveWorkbook.Sheets(1).Range("A1")
rSource.Copy rDest
ActiveWorkbook.Close True

End Sub


You should also add error handling in case the file can't be found
in the specified location.
"Mikeice" wrote:


Hi Excel Gurus.

I have bought so many VBA books but can't find the solution.

What I need to do is export or import (whatever is best.)
a range from an open work book to a closed workbook.

Range a1 to I55

how can I do this?

Please give us some ideas and I will see if I can get my money out of
these books.

thx


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=387059


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Exporting to a closed workbook

Mikeice,
ADO can work with closed workbooks, if it is straight data in a
database-like structure.

NickHK

"Mikeice" wrote in
message ...

Hi Excel Gurus.

I have bought so many VBA books but can't find the solution.

What I need to do is export or import (whatever is best.)
a range from an open work book to a closed workbook.

Range a1 to I55

how can I do this?

Please give us some ideas and I will see if I can get my money out of
these books.

thx


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile:

http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=387059



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
Open a closed workbook with VBA ttomlinson[_2_] Excel Programming 8 May 30th 05 06:53 PM
Value from a closed workbook Anthony Slater Excel Discussion (Misc queries) 5 May 17th 05 09:49 AM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Getting value from closed workbook Dyawlak Excel Programming 1 April 22nd 04 02:20 AM
find in closed workbook marko Excel Programming 0 November 25th 03 12:52 PM


All times are GMT +1. The time now is 12:13 AM.

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

About Us

"It's about Microsoft Excel"