View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default Character symbol meaning

Thank you all!
Rick, I really appreciate your explanation and assistance in an alternative.

"Rick Rothstein" wrote:

The code is attempting to locate the location within the text assigned to
the variable 'str2'. This section (in the assignment to 'lastw')...

Len(str2) - Len(.Substitute(str2, " ", ""))

counts the number of spaces in the original text (it does this by finding
the difference between the length of the original text and the text with all
its spaces removed. Then the code uses this number (of spaces) in the
worksheet's Substitute function to replace the last space with a "^" symbol.
This code then assigns the original text with the last space changed to a
"^" symbol to the 'lastw' variable. The next line then locates the "^"
symbol (using the worksheet's Find function) and returns that position
number to the 'lasti' variable.

Okay, that is what the code is doing... the "^" symbol has no special
meaning... any character that would be found in the original text would work
as well. Just so you know, the code you posted is not an efficient way to
locate the last space in a text string. Here is how I would do it with a
single line of code...

lasti = InStrRev(str2, " ") + 1

--
Rick (MVP - Excel)


"Liz" wrote in message
...
Hi -
Can someone tell me what the "^" symbol in the below variables is? Is this
a
symbol for space or end of line?

lastw = .Substitute(str2, " ", "^", Len(str2) - Len(.Substitute(str2, " ",
"")))
lasti = .Find("^", lastw) + 1

Thanks,
Liz