Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help...Code to copy sheet from closed workbook | Excel Discussion (Misc queries) | |||
Possible to copy sheets into another (closed!) workbook? | Excel Discussion (Misc queries) | |||
copy worksheet from closed workbook to active workbook using vba | Excel Worksheet Functions | |||
copy to a Closed workbook. whith Path . | Excel Programming | |||
How to copy a range to a closed workbook | Excel Programming |