Sub BackupFoglioAttivo()
Dim nf, Nomefile, p As String
Dim Sht As Worksheet
nf = Range("C16").Value 'nome del foglio che si registra
Nomefile = nf & ".xlsx"
cartella = Range("F14").Value 'nome della cartella che si vuole registrare
percorso = "D:AMICIEVENTI" & cartella & ""
ActiveSheet.Copy
ActiveWorkbook.SaveAs percorso & "" & Nomefile & " "
Application.ScreenUpdating = False
For Each Sht In Worksheets
With Sht
.Select
Range(.UsedRange.Address) = (Range(.UsedRange.Address))
ActiveSheet.Name = Nomefile
ActiveWorkbook.Save
End With
Next Sht
ActiveWorkbook.Close
MsgBox "D' STATO SALVATO" & file, vbInformation, "Excel"
End Sub |