Thread: left()
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default left()

If it doesn't find ! in the string poz, then the Instr returns 0. Subtract 1
from that, and you are then trying to get the leftmost -1 characters. Hence,
it is invalid.

You should test it

if InStr(poz, "!") 0 Then
b=Left(poz, InStr(poz, "!") - 1)
Else
b = poz
End If


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"mpele" wrote in
message ...

Why the command

b=Left(poz, InStr(poz, "!") + 1)

is working and

b=Left(poz, InStr(poz, "!") - 1)

doesn't work? It say: Invalid procedure call or argument...


--
mpele
------------------------------------------------------------------------
mpele's Profile:

http://www.excelforum.com/member.php...o&userid=31808
View this thread: http://www.excelforum.com/showthread...hreadid=520041