#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default left()


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default left()

Hi M,

If the exclamation character (!) is found, both expressions work for me.

If however, the character is not found, then the exptrssion:

InStr(poz, "!") - 1

equates to -1 which is an invalid in the Left function,


---
Regards,
Norman



"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default left()


Norman Jones Wrote:
Hi M,

If the exclamation character (!) is found, both expressions work for
me.

InStr gives result 6 but I need value 5 for function left.
What am I doing wrong? or what can I do wrong?!?



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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default left()

Hi M,

Your error is consistent with the exclamation character not being found.

If the expression:

InStr(poz, "!")

returns 6, as you suggest, I would not expect either of your original
expressions:

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

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


to produce your encountered error.


---
Regards,
Norman



"mpele" wrote in message
...

Norman Jones Wrote:
Hi M,

If the exclamation character (!) is found, both expressions work for
me.

InStr gives result 6 but I need value 5 for function left.
What am I doing wrong? or what can I do wrong?!?



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



Reply
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
LEFT function-all to left of a comma? Jennifer F Excel Worksheet Functions 1 January 21st 09 11:19 PM
when inserting new worksheets they read right to left not left to. Andy Setting up and Configuration of Excel 2 December 3rd 08 09:51 PM
My Excel view is Right to Left instead of Left to Right !!! Akash Puri Excel Discussion (Misc queries) 2 May 5th 08 07:15 PM
Column labels run right to left, not left to right tmassey Excel Discussion (Misc queries) 1 November 10th 06 11:03 AM
How to change the right-to-left worksheet to left-to-right workshe RAMA Excel Discussion (Misc queries) 1 July 4th 05 01:57 PM


All times are GMT +1. The time now is 04:28 PM.

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

About Us

"It's about Microsoft Excel"