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

I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default copy data from a closed workbook

Hi Christy

You must set a reference
See website
http://www.rondebruin.nl/ado.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default copy data from a closed workbook

Hi Christy

See also this page if you want to create formula links
http://www.rondebruin.nl/summary2.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default copy data from a closed workbook

Hi Ron,

THNAKS for all the help you give to everyone on this forum.

I guess I don't know what you mean. I checked "Microsoft ActiveX Data
Objects 2.5 Library". Your sample runs but not my workbook??

"Ron de Bruin" wrote:

Hi Christy

You must set a reference
See website
http://www.rondebruin.nl/ado.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy




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

I have already set the reference in the sample workbook on my site.

If you copy the code in your own workbook you must do it in this workbook also.
In the VBA editor select your file first in the project explorer and then set the reference.
Save the file then.



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



"Christy" wrote in message ...
Hi Ron,

THNAKS for all the help you give to everyone on this forum.

I guess I don't know what you mean. I checked "Microsoft ActiveX Data
Objects 2.5 Library". Your sample runs but not my workbook??

"Ron de Bruin" wrote:

Hi Christy

You must set a reference
See website
http://www.rondebruin.nl/ado.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default copy data from a closed workbook

It is set in both the workbook that I am running the code from and the closed
workbook I want to get the data from and I still get the same error???

"Ron de Bruin" wrote:

I have already set the reference in the sample workbook on my site.

If you copy the code in your own workbook you must do it in this workbook also.
In the VBA editor select your file first in the project explorer and then set the reference.
Save the file then.



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



"Christy" wrote in message ...
Hi Ron,

THNAKS for all the help you give to everyone on this forum.

I guess I don't know what you mean. I checked "Microsoft ActiveX Data
Objects 2.5 Library". Your sample runs but not my workbook??

"Ron de Bruin" wrote:

Hi Christy

You must set a reference
See website
http://www.rondebruin.nl/ado.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default copy data from a closed workbook

It is set in both the workbook that I am running the code from
Send me your test file private and I look at it

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



"Christy" wrote in message ...
It is set in both the workbook that I am running the code from and the closed
workbook I want to get the data from and I still get the same error???

"Ron de Bruin" wrote:

I have already set the reference in the sample workbook on my site.

If you copy the code in your own workbook you must do it in this workbook also.
In the VBA editor select your file first in the project explorer and then set the reference.
Save the file then.



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



"Christy" wrote in message ...
Hi Ron,

THNAKS for all the help you give to everyone on this forum.

I guess I don't know what you mean. I checked "Microsoft ActiveX Data
Objects 2.5 Library". Your sample runs but not my workbook??

"Ron de Bruin" wrote:

Hi Christy

You must set a reference
See website
http://www.rondebruin.nl/ado.htm


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



"Christy" wrote in message ...
I found this code on Ron's site and it is exactly what I need. I was able to
download and run his example just fine but when I put the exact code in my
workbook I get 'Subscript out of range'. I pasted the functions in one
module and the macros in another just like in the example.

I have not even tried to modify the from and to ranges yet. Any help will be
greatly appreciated.

Sub GetData_Example2()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else
GetData FName, "Sheet1", "A1:C5", Sheets("Sheet1").Range("A1"), False
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub

Christy








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
Help...Code to copy sheet from closed workbook [email protected] Excel Discussion (Misc queries) 1 March 28th 07 08:52 PM
Possible to copy sheets into another (closed!) workbook? Grotifant Excel Discussion (Misc queries) 5 February 23rd 05 08:55 AM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
copy to a Closed workbook. whith Path . willie30[_5_] Excel Programming 4 November 26th 04 07:55 AM
How to copy a range to a closed workbook max Excel Programming 1 July 16th 04 11:13 AM


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