View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
CrowBar CrowBar is offline
external usenet poster
 
Posts: 1
Default macro launched when condition is true


Place this code within your WORKSHEET. If the worksheet changes it then
checks the change against the code.

I have defined an coloumn and named the area "arrow", you need to set
your area name up and change this code as required



Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim VRange As Range, cell As Range
Dim Msg As String
Dim ValidateCode As Variant
Set VRange = Range("arrow")
For Each cell In Target

If Union(cell, VRange).Address = VRange.Address Then

If cell.Value = "" Then



ElseIf WorksheetFunction.IsNumber(cell.Value) = True Then
If cell.Value 4 Or cell.Value < 3 Then
MsgBox "Please enter a correct number, either 3 or 4 to
display an arrow"
cell.Value = ""
cell.Select
End If
Else
MsgBox "Please enter a correct number, either 3 or 4 to
display an arrow"
cell.Value = ""
cell.Select
End If

Exit For
Exit Sub
End If
Next


--
CrowBar
------------------------------------------------------------------------
CrowBar's Profile:
http://www.excelforum.com/member.php...o&userid=34716
View this thread: http://www.excelforum.com/showthread...hreadid=545120