Character symbol meaning

L

Liz

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
 
G

Gary''s Student

In formulas, it represents to the operator to raise a value to a power:

=7^3
same as
=7*7*7
same as
343
 
J

Jacob Skaria

In your case it is a text character....

In Ms Excel the 'Caret' operator is raise to the power of ....

=3^2

is 3 raised to the power of 2 which is 9


If this post helps click Yes
 
L

Liz

Thank you Gary. Can it mean something different for a string? I have a
string in this cell and not sure what these variables are doing....I know
they are supposed to find the last word in the cell and extract it.

Thanks,
Liz
 
R

Rick Rothstein

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
 
F

FSt1

hi
without seeing the rest of your code, i'm guessing but..... it appears that
its a marker of some sort because after the substituting in the frist line,
the second line tries to find the marker and then adds 1 to what ever the
find returns.

like i said...wild guessing here.

Regards
FSt1
 
R

Rick Rothstein

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."
 
L

Liz

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

Patrick Molloy

it used to, in very early versions of Excel, to indicate alignment. Where a
single quote ' meant align left and a cap, ^, meant align centre.
In your code, the ^ replaces the spaces in the text. Maybe there's some
issue whereby spaces aren't legitimate.....for example where the text is
used to create a range name (mind you, ^ isn't legal either!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top