Have this formula perform for each row instead of just one.

0

I have this formula that works well for one row.

How do I make this formula perform the same way for each row?

What it does, is when something is entered in B2, a warning pops up requireing something to be entered into D2. You can't continue unless you do.

I want this for all rows, enter something into B5, you need something in D5.

Thanks

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim B As Range, D As Range
Set B = Range("B2")
Set D = Range("D2")
If B <> "" And D = "" Then
Application.EnableEvents = False
D.Select
Application.EnableEvents = True
MsgBox "Your ID Number is Required"
End If
End Sub
Answer
Discuss

Answers

0

Use the Change event and not the Selection change event.

This macro should work for you:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 2 And Target.Offset(, 2).Value = "" Then

    MsgBox "Your ID Number is Required"

End If

End Sub

The first 2 is for column B and the second 2 is how many columns to the right you want to check; so, two to the right of column B is column D.

Discuss

Answer the Question

You must create an account to use the forum. Create an Account or Login