Dear all,
I am trying to write macro which would start when open the workbook, then the user make necessary changes and macro will start again after close + save the workbook.
Please find a dummy code below:
Main:
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Userform1:
Private Sub CommandButton1_Click()
Range("A1").Value = "You"
End Sub
Private Sub CommandButton2_Click()
Range("A1").Value = "I"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim ws As Worksheet
Dim pwd As String
pwd = "Hi" ' Put your password here
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
End Sub
I am struggling with the last part. I need to run different macro when exiting and saving the workbook, depending on Userform CommandButton choice at the begining.
Is there a way to do it?
Thanks a lot!
Bookmarks