shazadhussain88
New Member
- Joined
- Oct 13, 2023
- Messages
- 14
- Office Version
- 365
- Platform
- Windows
Hi all,
Hopefully you guys can help a real newbie with an issue im having with a Macro.
I have a excel file which i would like to share with my team to populate. There is a field where either a Yes or No option must be filled. The default field is 'Please Select'. I have added the below code which prevents the users from saving the file without entering either Yes or No.
Looks to be working fine, however now I am unsure how to save this template to distribute to the team!, as it keeps asking me to select yes or no. I want to save it as 'please select' and share with the team who from this point must select either yes or no. hopefully this makes sense!
ANy help would be appreciated !
Hopefully you guys can help a real newbie with an issue im having with a Macro.
I have a excel file which i would like to share with my team to populate. There is a field where either a Yes or No option must be filled. The default field is 'Please Select'. I have added the below code which prevents the users from saving the file without entering either Yes or No.
Looks to be working fine, however now I am unsure how to save this template to distribute to the team!, as it keeps asking me to select yes or no. I want to save it as 'please select' and share with the team who from this point must select either yes or no. hopefully this makes sense!
ANy help would be appreciated !
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Dim rng As Range
For Each rng In Sheets("DCR").Range("E18:F18")
If rng = "Please Select" Then
MsgBox ("Please select 'Yes' or 'No' in cell " & rng.Address(0, 0))
Cancel = True
Exit For
End If
Next rng
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ScreenUpdating = False
Dim rng As Range
For Each rng In Sheets("DCR").Range("E18:F18")
If rng = "Please Select" Then
MsgBox ("Please select 'Yes' or 'No' in cell " & rng.Address(0, 0))
Cancel = True
Exit For
End If
Next rng
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: