![]() |
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. |
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. |
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. |
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. |
All times are GMT +1. The time now is 05:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com