XLA routines: EE_OpenFileFromCell

Nick's picture
EE_OpenFileFromCell is a routine that one would use to add to a button - select a cell containing a file name, and press the button to open the file in the Excel session - useful for debugging input files - works with a file name or full path
Sub EE_OpenFileFromCell(rngFileCell As range)
    Dim rngCell As range
 
'http://excelexperts.com/xla-routines-eeOpenFileFromCell    for updates on this sub routine

    For Each rngCell In rngFileCell
        On Error Resume Next
        If InStr(rngCell.value, Application.PathSeparator) > 0 Then
            Application.Workbooks.Open rngCell.value
        Else
            Application.Workbooks.Open ThisWorkbook.Path & Application.PathSeparator & rngCell.value
        End If
        Err.Clear: On Error GoTo 0: On Error GoTo -1
    Next rngCell
    Set rngCell = Nothing
End Sub