• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Screen updating message

Hi All I am using following code to extract wks from different wbs with same name. I am still getting screen alert of update/don't update. Can you suggest the correction in the code to avoid the alert? Thanks
Sub CombineSheets()
    Dim sPath As String
    Dim sFname As String
    Dim wBk As Workbook
    Dim wSht As Variant

    Application.EnableEvents = False
    Application.ScreenUpdating = False
    sPath = InputBox("Enter a full path to workbooks")
    ChDir sPath
    sFname = InputBox("Enter a filename pattern")
    sFname = Dir(sPath & "\" & sFname & ".xl*", vbNormal)
    wSht = InputBox("Enter a worksheet name to copy")
    Do Until sFname = ""
        Set wBk = Workbooks.Open(sFname)
        Sheets(wSht).Copy Before:=ThisWorkbook.Sheets(1)
        wBk.Close False
        sFname = Dir()
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub


Try To add This 2 line at the top an bottom

Application.DisplayAlerts = False
Application.DisplayAlerts = True


Excel Ninja
... really - it don't matter?
a) by fixing Your code that it allows updating always
b) test to add three lines
After Sub -line On Error Resume Next
before Application.EnableEvents = False line Application.DisplayAlerts = False
before End Sub -line Application.DisplayAlerts = True
>>> and >>>
be ready, that You could miss many things = have a backup