Hello,
I am at stuck with a VBA code or a workaround and would greatly appreciate any help... if its even possible with Excel. I have a list of passwords and Workbook names in a 'Master' workbook. The data is on a sheet called 'Passwords'. Column A in the 'Passwords' sheet lists some Workbook names and column B contains passwords to open the workbook. All of the password protected workbooks will stay in the same folder as the 'Master' Workbook.
Essentially I am trying to figure out a VBA script that will search the 'Passwords' sheet. Match it up to the corresponding workbook. Unlock the workbook. And Wait.
Separately there needs to be a code that will run that in reverse. Search 'Passwords' and replace the password on the protected workbook. This is so other macros can run through the now unlocked workbooks and then once finished, lock them again.
I found a code through other research but it seems to not do anything when I click and im not sure this is exactly what I am needing.
Sub Robot()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Passwords")
Dim Loc As String: Loc = "C:\Users"
Dim pw As String, fn As String, cb As Workbook, i As Long
'Loc = Local Location
'pw = Password
'fn = File Name
'cb = Current Book
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For i = 2 To ws.Range("A" & ws.Rows.Count).End(xlUp).Row
On Error Resume Next 'If book does not exist
fn = Loc & ws.Range("A" & i)
pw = ws.Range("B" & i)
On Error GoTo 0
Next i
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Again, any help is greatly appreciated. Even if there is another way next to VBA I am open to it. It is taking to much time to start a macro (not included here) and be prompted on every workbook to enter a password. The macro errors out if you mistype the password or similar and simply takes awhile every morning when we run it. It would be a huge time saver to allow VBA to unlock them all.
Bookmarks