Excel 365 cell needs initial value of blank, but can only have a value of 'Y' or 'N'.

I have a working Excel 365 spreadsheet, type xlsm, that I need to add a cell to.  This spreadsheet is used for entry purposes and incorporates much VB for applications.  I need to add a field that will be limited to field values of 'Y' or 'N' and will provide an error message when an invalid value is entered.  This is basic using the Data Validation button in Excel.  My problem arises since I need this field to have an INITIAL value of blank or space.  I do initialize the field in the VB code upon opening the spreadsheet to a value of " ".  This also works yet once the spreadsheet is opened, it does not force the user to enter either a 'Y' or 'N' in the field.  It will only give an error message if another value is entered into the field.  So, it can be printed or saved with a blank in the field even though it restricts ENTRY to 'Y' or 'N'.  Does anybody know a way around this.  So I can have the spreadsheet open up with no value in the field but still force them to enter a 'Y' or 'N' before printing or saving?  Thank you very much!
mjchevalierAsked:
Who is Participating?

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

x
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.

Saurabh Singh TeotiaCommented:
You can use a simple code like this...Please insert this code in the thisworkbook module...

Also i have assumed that in sheet1 range a1 can't be blank before print or save...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
 
 If Sheets("sheet1").Range("A1").Value = "" Then
        MsgBox "Please fill the value in order to print"
        Cancel = True
    End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   If Sheets("sheet1").Range("A1").Value = "" Then
        MsgBox "Please fill the value in order to save"
        Cancel = True
    End If
End Sub

Open in new window


Saurabh...

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
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
Office 365

From novice to tech pro — start learning today.