ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Change (https://www.excelbanter.com/excel-programming/317716-worksheet-change.html)

SeanEvans[_4_]

Worksheet Change
 

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

--
SeanEvan
-----------------------------------------------------------------------
SeanEvans's Profile: http://www.excelforum.com/member.php...fo&userid=1465
View this thread: http://www.excelforum.com/showthread.php?threadid=32012


shieb[_4_]

Worksheet Change
 

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

--
shie
-----------------------------------------------------------------------
shieb's Profile: http://www.excelforum.com/member.php...fo&userid=1640
View this thread: http://www.excelforum.com/showthread.php?threadid=32012



All times are GMT +1. The time now is 11:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com