Good Afternoon All,
The code below works, when the file is in the process of opening, it appears Excel is opening and closing all of the workbooks and then finally opens the correct one. It's not visually appealing. I am curious to know, if when a filename is selected if the below code can be tweaked to just open the specific workbook? I have tried several IF/THEN statements and did not have much luck. Thank you for having a look.
The code below works, when the file is in the process of opening, it appears Excel is opening and closing all of the workbooks and then finally opens the correct one. It's not visually appealing. I am curious to know, if when a filename is selected if the below code can be tweaked to just open the specific workbook? I have tried several IF/THEN statements and did not have much luck. Thank you for having a look.
Code:
Private Sub btnOpenFile_Click()
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Dim fileH As String
Dim fileJ As String
Dim fileMI As String
Dim fileMT As String
Dim fileO As String
Dim fileP As String
If lstVAFiles.ListIndex < 0 Then
MsgBox ("You must select a file!"), , "User Error"
Exit Sub
End If
fileH = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileH)
fileJ = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileJ)
fileMI = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileMI)
fileMT = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileMT)
fileO = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileO)
fileP = lstVAFiles.List(lstVAFiles.ListIndex, 1) & lstVAFiles.List(lstVAFiles.ListIndex, 2)
Workbooks.Open (fileP)
'Workbooks.Open (fileH)
'Workbooks.Open (fileJ)
'Workbooks.Open (fileMI)
'Workbooks.Open (fileMT)
'Workbooks.Open (fileO)
'Workbooks.Open (fileP)
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Last edited: