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 (ADO)

I am using code provided at Ron's web site and with his help (Thanks Ron!)
and help form this forum I got the code to work except I am not getting the
data I expect.

On the Saturday sheet, cell b2 contains a date and cell b3 has city/state/zip

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

****When I run either****

GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2"), False
Or
GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2:b3"), False


I get the city/state/zip in b2 (no date)

When I run

GetData FName, "Saturday", "b1:b3", Sheets("Source").Range("b2:b3"), False

I get the date in b2 (no city/state/zip)

I need to be able to select the source file since the filename will not be
known to hard code it. Any help is greatly appreciated!

Christy ;)

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

Hi

Look at the last argument (False /True)
Header yes or No

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



"Christy" wrote in message ...
I am using code provided at Ron's web site and with his help (Thanks Ron!)
and help form this forum I got the code to work except I am not getting the
data I expect.

On the Saturday sheet, cell b2 contains a date and cell b3 has city/state/zip

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

****When I run either****

GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2"), False
Or
GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2:b3"), False


I get the city/state/zip in b2 (no date)

When I run

GetData FName, "Saturday", "b1:b3", Sheets("Source").Range("b2:b3"), False

I get the date in b2 (no city/state/zip)

I need to be able to select the source file since the filename will not be
known to hard code it. Any help is greatly appreciated!

Christy ;)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Copy data from a closed workbook (ADO)

Thanks Ron. I figured it had something to do with headers.

I was able to get the code to work by copying the data one cell at a time. I
had to include an extra cell above the one I wanted in the source range. I
guess the true/false indicates if you want to copy a header row which must be
included in the range either way?

Anyway, it works great now. It does run a little slow and I will be
checking out your "Create a summary sheet from different workbooks" code next.

Thanks again
Christy ;)

"Ron de Bruin" wrote:

Hi

Look at the last argument (False /True)
Header yes or No

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



"Christy" wrote in message ...
I am using code provided at Ron's web site and with his help (Thanks Ron!)
and help form this forum I got the code to work except I am not getting the
data I expect.

On the Saturday sheet, cell b2 contains a date and cell b3 has city/state/zip

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

****When I run either****

GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2"), False
Or
GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b2:b3"), False


I get the city/state/zip in b2 (no date)

When I run

GetData FName, "Saturday", "b1:b3", Sheets("Source").Range("b2:b3"), False

I get the date in b2 (no city/state/zip)

I need to be able to select the source file since the filename will not be
known to hard code it. Any help is greatly appreciated!

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
copy data from a closed workbook Christy Excel Programming 6 March 3rd 05 09:01 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
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 12:11 AM.

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"