If cell L6 shows yes or no, a message box appears to confirm cell L7 and L8 must be completed . I saw a similar post, but I couldn't get the VBA coding to work for my situation. Any help would be appreciated, thank you.
41 Answer
To achieve the goal, I would like to suggest two possible methods.
Method 1, Data Validation:
- Situation 1, when Cell
L6is filled with eitherYesorNo.
- Situation 2, when Cell
L6is filled with neitherYesnorNo.
- Situation 3, when Cell
L6isBlank.
How it works:
- Select cells
L7&L8and from Data Tab click Data Validation. - Set Custom as Validation Criteria and enter this Formula.
=NOT(ISBLANK($L$6))*(OR($L$6="Yes",$L$6="No"))
- Finish with Ok
Method 2, VBA (Macro):
- Right Click the Sheet Tab & hit View Code from the Poped up menu to get VB editor.
Copy & Paste this Code as Standard Module with the Sheet.
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("L6")) Is Nothing Then If Target.Value = "Yes" Or Target.Value = "No" Then MsgBox "Now You Can fill L7 & L8" Range("L7").Activate ElseIf Target.Value <> "Yes" Or Target.Value <> "No" Then MsgBox "Target cell must have data Yes Or No,, to fill L7 & L8" Target.Activate End If If Target.Value = "" Then MsgBox "Target Cell Can't be Blank,," Target.Activate End If End If End Sub
N.B.
This code will start responding as soon you fill the Cell
L6.You may adjust cell references in the Formula as well as in VBA code as needed.