First time poster, and let me apologize right off the bat if I'm asking a question that has already been answered. I've tried searching for an answer but haven't found what I need yet.
I'm also a first-timer to VBA as I'm finishing up my first project. I don't really know coding that well but have been able to pick up everything I've needed by searching around the web. But the very last piece of the puzzle is stumping me.
I've created a form that is populated by the user filling out a series of UserForms which then insert the answers into the form when a "Next" button is clicked, and depending on certain answers changes the way the form looks. It all works pretty well, so no problem there. I also didn't want the user modifying their answers outside of an Edit button that I placed in the form, so I protected the sheet and added additional code that allows the UserForms to still insert the answers. Again, no problems there. Rather than the standard Microsoft notice about the sheet being protected I wanted the user to receive a custom message when they clicked in the protected sheet, so I added this code to the tab where the form exists:
It does what I want it to do but now the custom message shows up whenever the UserForms try to insert the answers. I don't want that to happen so I added Application.EnableEvents = False at the beginning of the "Next" button code on the first UserForm and then returned the value to True at the end.
It works, but doesn't seem to return the value back to True. Once I click the "Next" button the custom message doesn't appear when I click the protected sheet. Shouldn't returning the EnableEvents value back to True allow the custom message to show up again?
I'm also a first-timer to VBA as I'm finishing up my first project. I don't really know coding that well but have been able to pick up everything I've needed by searching around the web. But the very last piece of the puzzle is stumping me.
I've created a form that is populated by the user filling out a series of UserForms which then insert the answers into the form when a "Next" button is clicked, and depending on certain answers changes the way the form looks. It all works pretty well, so no problem there. I also didn't want the user modifying their answers outside of an Edit button that I placed in the form, so I protected the sheet and added additional code that allows the UserForms to still insert the answers. Again, no problems there. Rather than the standard Microsoft notice about the sheet being protected I wanted the user to receive a custom message when they clicked in the protected sheet, so I added this code to the tab where the form exists:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Locked = True Then
MsgBox "yada, yada, yada"
End If
Application.EnableEvents = True
End Sub
Code:
Private Sub NextButton1_Click()
Application.EnableEvents = False
'lots of working code here
Application.EnableEvents = True
End Sub