View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Character symbol meaning

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.


I left out the word "not" in the above description; it should have read...

"Okay, that is what the code is doing... the "^" symbol has no special
meaning... any character that would ***NOT*** be found in the
original text would work as well."

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
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