LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default What's Wrong With This Function?

On Thu, 23 Oct 2003 07:15:21 -0700, "Josh in Tampa"
wrote:

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!!!



Your function returns the value in TrimZip. Since you never set it, it
contains a 0.

Try:

Function TrimZip(OrigVal)

If InStr(OrigVal, "-") Then

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

End If

End Function


--ron
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with this function? DogmaDot Excel Discussion (Misc queries) 1 February 24th 10 04:00 PM
What's wrong with this IF function. GEM Excel Discussion (Misc queries) 5 July 24th 09 11:51 PM
What is Wrong with this function?????????? TaraD Excel Worksheet Functions 2 September 8th 06 07:47 PM
What am I doing wrong with PMT function? Marc Excel Discussion (Misc queries) 6 May 6th 06 10:35 PM
INDIRECT Function - what am I doing wrong? MACRE0 Excel Discussion (Misc queries) 2 October 5th 05 08:47 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"