View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Left vs Left$ function

And the reason you'd use one or the other is that Left$ may be quicker if
all you're doing is manipulating strings, while Left would help if you're
going to encounter the situation Ron describes.

There are also such functions as Right$ and Mid$.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Ron Coderre" wrote in message
...
I don't recall Excel having a LEFT$() worksheet function, BUT it is used in
VBA.

Here's the differece (as I understand it)

LEFT(string, num_chars) returns a VARIANT.

But, in LEFT$(string, num_chars), the trailing dollar sign ($) declares
the
return value to be a STRING.

It would make a difference if the 1st argument could be null.

Example:
In the immediate window of the VB Editor....

If you enter DEBUG.PRINT LEFT(NULL,3)
This is returned: NULL

But, if you enter DEBUG.PRINT LEFT$(NULL,3)
you get this error: "Invalid use of null",
because a STRING cannot be null.

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Andy" wrote:

Can someone explain the difference between the two of these? Thanks!