此代码打开了一组工作簿,并且可以正常工作。但是,在打开工作簿之后,我希望从中运行宏的主工作簿被激活并置于最前面。 这是我的代码,它不会激活并将excel主文件置于最前面。
Sub SkipBlankCells2()
Dim cell As Range, rng As Range, FName As String
Set rng = Range("E12:E24")
'Disable Screen Updating - stop screen flickering
' And Disable Events to avoid inturupted dialogs / popups
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Application.DefaultFilePath = ActiveWorkbook.Path
For Each cel In rng
If Len(cel) >= 1 Then
FName = cel.Value
Workbooks.Open Filename:=FName
End If
Next cel
'Enable Screen Updating and Events
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
'Return to master workbook
ThisWorkbook.Activate
End Sub