I have recorded below macro to unprotect sheet with password, autofileter some criteria and result if any copy to new workbook and save in c:\folder and again protect original sheet with password.
I just want to remove below two line from macro as let user decided to save file with name and folder instead of auto save to c:\report folder. but how to select original file again for protect sheet with password afte copy data to new sheet.
now after removing below two lines autofiler applying to new workbook file instead of original sheet2. pls guide
Worksheets("sheet2").Unprotect Password:="xxx"
Range("a1:a1000").AutoFilter 1, vbRed, xlFilterCellColor
If Range("A" & Rows.Count).End(xlUp).Row > 1 Then
Range("D1", Range("ag1000").End(xlUp)).Copy
Workbooks.Add
[a1].PasteSpecial xlValues
[a1].PasteSpecial xlPasteFormats
ActiveWorkbook.SaveAs "C:\report " & fname & ".xlsx"
ActiveWorkbook.Close False
Selection.AutoFilter
Worksheets("sheet2").Protect Password:="xxx"
End If
End Sub
Bookmarks