Hi Mr Excel and hope you can help me please?
As a relatively newcomer to VBA, but being quite good with excel, I need to create a form that requires a series of Yes/No inputs (Yes/No drop downs)
Based on some of these inputs I need a dialog box to pop up giving guidance to the user of the required step if Yes is selected.
So, I have done this for when a single cell is selected, which works well –
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = 7 Then
If Target.Value = "Yes" Then
MsgBox "You must contact a Health & Safety Representative before proceeding."
End If
End If
End Sub
I have done this when the top 6 question boxes require a pop up box using a range when Yes is selected
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, r As Range
Set A = Range("D7:D16")
If Intersect(Target, A) Is Nothing Then Exit Sub
For Each r In Target
If r.Value = "Yes" Then
MsgBox "You must contact a Health and Safety Representative before proceeding.", vbExclamation, " New Sourcing Request"
End If
Next r
End Sub
BUT - I need a pop up to appear when other cells, not in a range, where Yes has been selected for example D16, E24, C12 on a single worksheet for which different Messages are required
Can you help please?
THANK YOU
As a relatively newcomer to VBA, but being quite good with excel, I need to create a form that requires a series of Yes/No inputs (Yes/No drop downs)
Based on some of these inputs I need a dialog box to pop up giving guidance to the user of the required step if Yes is selected.
So, I have done this for when a single cell is selected, which works well –
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = 7 Then
If Target.Value = "Yes" Then
MsgBox "You must contact a Health & Safety Representative before proceeding."
End If
End If
End Sub
I have done this when the top 6 question boxes require a pop up box using a range when Yes is selected
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, r As Range
Set A = Range("D7:D16")
If Intersect(Target, A) Is Nothing Then Exit Sub
For Each r In Target
If r.Value = "Yes" Then
MsgBox "You must contact a Health and Safety Representative before proceeding.", vbExclamation, " New Sourcing Request"
End If
Next r
End Sub
BUT - I need a pop up to appear when other cells, not in a range, where Yes has been selected for example D16, E24, C12 on a single worksheet for which different Messages are required
Can you help please?
THANK YOU