You will need to tailor this to suit and adjust the error handling.Code:Function GetMax(strMatrix As String) As Long Dim strResult As String Dim strPullText As String 'If we get an error in this function it is because the sheet does not exist On Error GoTo NoPage 'Build the string to pull the value from the closed file strPullText = "'" & filePATH & "[" & fileMATRIX & "]" & Trim(strMatrix) & "'!R3C2" 'Pull the value from the closed file GetMax = Application.ExecuteExcel4Macro(strPullText) Exit Function NoPage: 'There was an error so return the fact that the matrix is missing GetMax = 0 Err.Clear End Function
filePATH and fileMATRIX are constants that I have setup in my project.
TJ



Reply With Quote

Bookmarks