Worksheet Change

  • Thread starter Thread starter SeanEvans
  • Start date Start date
S

SeanEvans

I need to regulate the entries made on a spreadsheet to column N.
amusing the following -

Private Sub Worksheet_Change(ByVal Target As Range)


If Target = "sent to TS for payment" Then End
If Target = "sent to Emma" Then End

MsgBox ("NO")

Else
End If
End Sub

Basically an entry made in column N must be one of the above condition
set in the IF statements. How do I set the range these IF statement
apply to
 
You could use something like this to evaluate changes to column N or th
14th column.


Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 14 Then
If Target = "sent to TS for payment" Or Target = "sent to Emma" Then
MsgBox "No"
Exit Sub
End If
End If
End Su
-------------------


An alternative is to name the range you want to evaluate instead o
looking at all of column N. In this example, my named range i
"EvalRange".


Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("EvalRange")) Is Nothing Then
If Target = "sent to TS for payment" Or Target = "sent to Emma" Then
MsgBox "No"
Exit Sub
End If
End If
End Su
-------------------


If you're just validating input, you might be better off using Data
Validation from Excel and not even use VBA.

HTH,
Steve Hie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top