Creating inout values for excel
Many thanks, Gord. Works good
Max
"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Hi Max
Change the ival initial value and re-define nums array.
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A1:A100")
If Intersect(Target, r) Is Nothing Then
Exit Sub
End If
vals = Array("N", "NE", "NW", "NNE", "NNW", "S", "SE", "SW", "SSE", "SSW")
nums = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
For Each rr In r
ival = -1
For i = LBound(vals) To UBound(vals)
If UCase(rr.Value) = vals(i) Then
ival = nums(i)
End If
Next
If ival -1 Then
rr.Value = ival
End If
Next
End Sub
Gord
|