Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA code to open and copy a file

Is there a way to take the date entered by the user in cell C6 and write code
to:

1) go find the file name that contains that date
2) open that file
3) copy it to a new worksheet in the original workbook

Thanks all for any suggestions.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default VBA code to open and copy a file

If you search by date alone, you could possibly return several files with
that date as part of the file name. If you can narrow the search to files in
only one folder the probability of many files being returned is reduced, but
there still could be more than one. If you have the date and another piece
of the file name or even if the date is at the beginning or end of the file
name it would help to home in on the file.

The rest is textbook operation.

"Tbone" wrote:

Is there a way to take the date entered by the user in cell C6 and write code
to:

1) go find the file name that contains that date
2) open that file
3) copy it to a new worksheet in the original workbook

Thanks all for any suggestions.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA code to open and copy a file

JLGWhiz,

The file will always be in a defined location and will have the same name
only the date will change each week. An example would be
C:\Employees\Active\ Current_01-29-07.xls

I would like for once the user types in the date, in this case the user
would type 1/29/07, the code would go to the C drive, find the file ending in
that same date (there will only be one) and open it, then bring a copy back
to the original workbook. How would I do that?

"JLGWhiz" wrote:

If you search by date alone, you could possibly return several files with
that date as part of the file name. If you can narrow the search to files in
only one folder the probability of many files being returned is reduced, but
there still could be more than one. If you have the date and another piece
of the file name or even if the date is at the beginning or end of the file
name it would help to home in on the file.

The rest is textbook operation.

"Tbone" wrote:

Is there a way to take the date entered by the user in cell C6 and write code
to:

1) go find the file name that contains that date
2) open that file
3) copy it to a new worksheet in the original workbook

Thanks all for any suggestions.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default VBA code to open and copy a file

Hi Tbone,


Dim DateName As String
DateName = Range("C6").Value
Workbooks.Open FileName:= _
"C:\Employees\Active\ Current_" & DateName & ".xls"

Alan


"Tbone" wrote in message
...
Is there a way to take the date entered by the user in cell C6 and write
code
to:

1) go find the file name that contains that date
2) open that file
3) copy it to a new worksheet in the original workbook

Thanks all for any suggestions.



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 file with code Steve Excel Discussion (Misc queries) 1 April 24th 09 08:21 PM
How to Open a file with the help of a code in Excel Pranay Shah New Users to Excel 3 August 22nd 07 02:42 PM
Code to Open Excel File Please Help Cole Excel Discussion (Misc queries) 2 July 10th 06 09:04 PM
How to open a zip file from the code? ana Excel Programming 1 April 26th 04 02:49 PM
VBA code to open file? pgoodale[_2_] Excel Programming 4 December 30th 03 01:41 PM


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