View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Creating inout values for excel

Gord,

How do I get "N" to return as zero in your sub?

--
Max
Singapore
http://savefile.com/projects/236895
Downloads:21,000 Files:365 Subscribers:65
xdemechanik
---
"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
So you want to type NNE in a cell and have it change in-cell to a number?

You can do that with event code but how will you error-check your input?

Here is sheet event code to change in-cell as you enter but I think you're
looking for trouble with no way to cross-check entries.

Edit vals and nums arrays for more values. I just posted 10

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(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
For Each rr In r
ival = 0
For i = LBound(vals) To UBound(vals)
If UCase(rr.Value) = vals(i) Then
ival = nums(i)
End If
Next
If ival 0 Then
rr.Value = ival
End If
Next
End Sub


Gord Dibben MS Excel MVP