Hi
I am pretty new to VBA, which I'm using and learning through work. I have to be careful of what information I give away due to DPA... but I have a file which I have created code to break down into multiple tabs based on say a shop name like Tesco, Asda etc so that all sales for Tesco populate on 1 tab and then the formula then saves each tab individually into a folder. The issue I'm having is each of these tabs needs to be saved down password protected but I need the password to be different for each shop. So for Tesco it could be 123 for Asda 456 etc. What's the easiest way to go about this? I have an excel list with the shop name and the password on a separate file. Is the easiest way to use this?
My code is as follows-
Public Sub Save()
Dim xWs As Worksheet
Dim xDir As String
Dim folder As FileDialog
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
If folder.Show <> -1 Then Exit Sub
xDir = folder.SelectedItems(1)
For Each xWs In Application.ActiveWorkbook.Worksheets
xWs.SaveAs xDir & "\" & xWs.Name, FileFormat = xlsx, Password = "Thisneedstobevaried"
Next
End Sub
Bookmarks