Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How do I copy data from a closed file.

I am working on an excel macro and I need to copy data from another excel
file on a shared network drive. Any suggestions on code needed to copy a
cell from a different file and paste in my file?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How do I copy data from a closed file.

The easiest way is to open the file and then grab the data:


Sub Macro1()
Workbooks.Open Filename:="N:\remote.xls"
Windows("remote.xls").Activate
Range("A83").Select
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste
End Sub

--
Gary''s Student


"Rob Moore" wrote:

I am working on an excel macro and I need to copy data from another excel
file on a shared network drive. Any suggestions on code needed to copy a
cell from a different file and paste in my file?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How do I copy data from a closed file.

Turn on the macro recorder and execute a successful find manually. Turn it
off and look at the code. Consult help for an interpretation of the
arguments.

With find it is always best to assign the values you want to the arguments
since they are persistent and may affect the success of your search.

Searching for a floating point number may not work because what is actually
stored in the cell (or calculated in the cell) may not be exactly what is
displayed because of formatting. If I use the options in the find dialog
(and an argument in the code) and search for Values rather than formulas, I
am successful.



If you search for 45.02 and the cell contains 45.0198763, then you probably
won't find it looking at formulas. Looking at Values would be successful.
At the same time, searching the same range for 45.0198763 is not successful
unless I look at formulas.

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote:

The easiest way is to open the file and then grab the data:


Sub Macro1()
Workbooks.Open Filename:="N:\remote.xls"
Windows("remote.xls").Activate
Range("A83").Select
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste
End Sub

--
Gary''s Student


"Rob Moore" wrote:

I am working on an excel macro and I need to copy data from another excel
file on a shared network drive. Any suggestions on code needed to copy a
cell from a different file and paste in my file?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How do I copy data from a closed file.

The fastest way:

With Range("B9")
.Formula = "='M:\Commonfolder\[Myfiles.xls]Sheet1'!F5"
.Formula = .Value
End With

--
Regards,
Tom Ogilvy

"Rob Moore" wrote:

I am working on an excel macro and I need to copy data from another excel
file on a shared network drive. Any suggestions on code needed to copy a
cell from a different file and paste in my file?

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How do I copy data from a closed file.

Based on Tom's example you can also use
http://www.rondebruin.nl/copy7.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rob Moore" wrote in message ...
I am working on an excel macro and I need to copy data from another excel
file on a shared network drive. Any suggestions on code needed to copy a
cell from a different file and paste in my file?

Thanks





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
CAN I IMPORT DATA FROM A CLOSED FILE TO A NEW WORKSHEET Paul Excel Discussion (Misc queries) 1 January 11th 07 02:30 PM
hi, i am trying to copy data to closed workbook ritu Excel Programming 2 April 24th 06 09:07 PM
Copy range from closed file nc[_2_] Excel Programming 11 March 15th 05 06:00 PM
Copy data from a closed workbook (ADO) Christy Excel Programming 2 March 4th 05 06:41 PM
copy data from a closed workbook Christy Excel Programming 6 March 3rd 05 09:01 PM


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