Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In Excel2000, I have the following function:
Function WC_Name(ByVal WC) WC_Name = Application.WorksheetFunction.VLookup(WC, Workbooks("master.xls").Worksheets("fall06").Range ("b4:n500"), 13, False) End Function The problem is that it does not work if the "master" file is not open. How can I have the function open the file if it isn't already? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this...
Function WC_Name(ByVal WC) dim wbk as workbook on error resume next set wbk = Workbooks("master.xls") on error goto 0 if wbk is nothing then set wbk = Workbooks.Open("C:\master.xls") end if WC_Name = Application.WorksheetFunction.VLookup(WC, _ wbk .Worksheets("fall06").Range("b4:n500"), 13, False) End Function -- HTH... Jim Thomlinson "snax500" wrote: In Excel2000, I have the following function: Function WC_Name(ByVal WC) WC_Name = Application.WorksheetFunction.VLookup(WC, Workbooks("master.xls").Worksheets("fall06").Range ("b4:n500"), 13, False) End Function The problem is that it does not work if the "master" file is not open. How can I have the function open the file if it isn't already? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sure this works with a function. It still only wotrks with the
file open. Thanks anyway. Jim Thomlinson wrote: Try this... Function WC_Name(ByVal WC) dim wbk as workbook on error resume next set wbk = Workbooks("master.xls") on error goto 0 if wbk is nothing then set wbk = Workbooks.Open("C:\master.xls") end if WC_Name = Application.WorksheetFunction.VLookup(WC, _ wbk .Worksheets("fall06").Range("b4:n500"), 13, False) End Function -- HTH... Jim Thomlinson "snax500" wrote: In Excel2000, I have the following function: Function WC_Name(ByVal WC) WC_Name = Application.WorksheetFunction.VLookup(WC, Workbooks("master.xls").Worksheets("fall06").Range ("b4:n500"), 13, False) End Function The problem is that it does not work if the "master" file is not open. How can I have the function open the file if it isn't already? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
todays's function, if I open file date changes | Excel Discussion (Misc queries) | |||
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. | Excel Programming | |||
File Browse Function (Open dialog box for choosing file) | Excel Programming | |||
How to insert Open File action in the IF Function? | Excel Discussion (Misc queries) | |||
Which function to use to open an .asc file? | Excel Programming |