View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
steve steve is offline
external usenet poster
 
Posts: 576
Default DOH!!!! I'm a BONEHEAD

Josh,

Actually - it's been a good exercise understanding InStr(), and catching all
the ins-n-outs of getting code to work.

My approach (for what it's worth) would have been dependent on length

If Len(OrigVal) = 0 Then
OrigVal = 0
ElseIf Len(OrigVal) 5 Then
OrigVal = Left(OrigVal,5)
Else
OrigVal = OrigVal
End If

Of couse you might want to check that the final OrigVal is numeric...
--
sb
"Josh in Tampa" wrote in message
...
please don't waste your time with this thread. bonehead
mistake. SORRY!!!!

-----Original Message-----
Function TrimZip(OrigVal)

If InStr(OrigVal, "-") Then

OrigVal = Left(OrigVal, (Len(OrigVal) - InStr
(OrigVal, "-")))

End If

End Function

when i use it in my worksheet, i get 0 (zero) instead of

a
trimmed zip code.

supposed to work like this.....if it finds something like:

33534-0098, it will trim it down to 33534.

any ideas? thanks in advance!!!
.