2014-03-13 41 views
0

是否可以從已關閉的excel工作簿中提取值,該工作簿的名稱是根據當前的工作表?是否可以從已關閉的excel工作簿中提取一個值,該工作簿的名稱是根據當前工作表中的值選擇的

例如,='[Bracket (KYLE GRAHAM).xlsx]BRACKET'!$F25是我想要查找的單元格,但不是KYLE GRAHAM,我想使用當前工作表中的單元格。

+0

'是否有可能從一個封閉的Excel workbook'拉值 - 可惜的是,只用公式 - 不是。 VBA可以幫助你 –

+0

你知道這樣一個宏嗎?我沒有多少運氣搜索互聯網 – user3416767

+1

你可以從[這裏](http://spreadsheetpage.com/index.php/tip/a_vba_function_to_get_a_value_from_a_closed_file/)和[這裏](http://stackoverflow.com/questions/13811398/refer-to-excel-workbook-by-path-based-cell-value-data?rq = 1) –

回答

0

這段代碼打開工作簿和捕獲然後細胞值再次關閉工作簿不顯示的操作:

Function WorkbookLookup(Path As String, SheetName As String, CellAddress As String) 
'Hides action and warnings 
Application.ScreenUpdating = False 
Application.DisplayAlerts = False 
'Saves the name of the current wb to return after action 
InitialWB = ActiveWorkbook.Name 
'opens the specified wb 
Workbooks.Open Path 
'captures the cell's value 
WorkbookLookup = Sheets(SheetName).Range(CellAddress).Value 
'closes the workbook 
ActiveWorkbook.Close False 
'activates the original wb 
Workbooks(InitialWB).Activate 
'turns on warnings and action display 
Application.ScreenUpdating = True 
Application.DisplayAlerts = True 
End Function 
相關問題