Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If i type a file name in cell "A2", is there a way to pick up that file name
from cell A2, look in a specific location and open it? and if not found, display a message that file was not found? Cheers, Mayte |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mayte,
Right-click on the sheet tab and choose View Code. In that code window, paste the following Private Sub Worksheet_Change(ByVal Target As Range) Dim FName As String Dim Path As String Dim WB As Workbook If Target.Address < "$A$2" Then Exit Sub End If ' Change Path to the desired folder name Path = "C:\Test" '<<<< CHANGE FName = Path & "\" & Target.Text If Dir(FName) = vbNullString Then ' file does not exist End If ' ensure that the workbook is not already open For Each WB In Workbooks If StrComp(FName, WB.FullName, vbTextCompare) = 0 Then Exit Sub End If Next WB Workbooks.Open Filename:=FName End Sub This will look at cell A2 and open the file if it exists and is not already open. Change the Path value as necessary. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Tue, 10 Mar 2009 15:02:01 -0700, Mayte wrote: If i type a file name in cell "A2", is there a way to pick up that file name from cell A2, look in a specific location and open it? and if not found, display a message that file was not found? Cheers, Mayte |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks a lot !!!
one more favour ..anyway to search in a folder and all sub-folders? cheers, mayte |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
No text search from File|Open in Excel 2007? | New Users to Excel | |||
what happened to file, open, tools, search? | Excel Discussion (Misc queries) | |||
Open Another File to Search and Replace Text | Excel Programming | |||
Macro to open search box? | Excel Programming |