Excel unprotect workbook and make a change to range name

I have an Excel workbook that is protected. The workbook password is AA12. I have a name range called EntityNumber. I need to change the EntityNumber. Is there Excel code that will

1 Allow me to select a workbook from a folder
2 Unprotect the workbook
3 Let me change the EntityNumber
4 Protect the workbook
5 let me save and close the file

Let me know if you need more information. Thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Assuming the password is only to open the Excel file and the named range EntityNumber has a workbook scope, you may try something like this...
Sub UnprotectWorkbookAndChangeRangeValue()
Dim wb As Workbook
Dim strFileName As String

Application.ScreenUpdating = False
With Application.FileDialog(msoFileDialogFilePicker)
    .Title = "Select Excel File!"
    .Filters.Add "Excel File", "*.xls*"
    .AllowMultiSelect = False
    If .Show = -1 Then
        strFileName = .SelectedItems(1)
        MsgBox "You didn't select any file!", vbExclamation
        Exit Sub
    End If
End With
Set wb = Workbooks.Open(strFileName, False, False, , "AA12")
wb.Names("EntityNumber").RefersToRange.Value = "Your value here"    'Change value here
wb.Close True
Application.ScreenUpdating = True
MsgBox "Task completed!", vbInformation
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ConernestoAuthor Commented:
Thank you very much.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.