Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default General Question on one line of code - parentheses and quotation marks

I don't understand the following line of code.
"=MID(R[0]C[-2],INDEX(FIND({""(403"",""(587""},R[0]C[-2]),MATCH(TRUE,ISNUMBER(FIND({""(403"",""(587""},R[0]C[-2])),0)),14)"

1. Why and when should square brackets be used?
2. Why & where should curved brackets be used?
3. Why are there double sets of quotation marks around the (403 and (587
4. I've never used the R[0]C[-2] nomenclature. Is this example designating a
cell location that is on the same row bur two columns left?
5. I can't find reference to MATCH(TRUE,ISNUMBER. What is this doing?

Thanks to anyone that takes the time to answer this.

Jim Berglund

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default General Question on one line of code - parentheses and quotationmarks

#1. When you're typing a formula into a cell in excel, you can use a formula
like this into C1:
=a1+b1
when the column headers are letters.

If the column headers are numbers, then the formula in C1 would be:
=RC[-2]+RC[-1]

The different style for those cell references for the way you type the formula
is determined by this setting:

Tools|Options|General Tab|Check or uncheck R1C1 Reference style.

The =a1+b1 formula is in A1 reference style.
The =rc[-2]+rc[-2] is in R1C1 reference style.

========
But you can write code in the VBE for your macro that uses either reference
style (but not a mixture).

You'd use:

activesheet.range("c1").formula = "=a1+b1"
activesheet.range("c1").formulaR1C1 = "=RC[-2]+RC[-1]"

When the macro runs, excel will plop the formula into the cell. But it'll be
displayed in the formula by that setting (R1C1 reference style). You and your
code don't need to worry about the setting.

Your expression was written as a .formulaR1C1 string.

The R[0]C[-2] portion says:
Stay on the same row (0 in those []'s) as the cell with the formula.
But use the cell two columns to the left (-2 in the []'s).

The cell that would be used depends on what cell the formula gets plopped into.

You can add some test formulas to a worksheet and toggle this R1C1 reference
style setting to see how your formulas get converted from one reference style to
the other.

#2. Those ()'s are required for some functions and other times, they're used to
make the meaning of the expression less ambiguous to the human eye.

=sum(a1:a10)
requires the ()'s.

=a1+b1/c2*d3
doesn't need any ()'s
but I would find this easier to understand:
=a1+((b1/c2)*d3))

I wouldn't need to worry about what was intended and how excel will use its
order of operator precedence to determine the result.

#3. When you build a string expression in code and that string includes double
quotes, you have to double them up.

#4. Yep.

#5. the =find(...), is going to result in either a number (if it's found) or an
error if it's not found. The expression used will result in an array of those
numbers/errors.

So =isnumber(find(...)) will result in True's if it was found or false if it
wasn't. (Errors are not numbers.) The expression used will result in an array
of those True/False values.

=match(true,(thatarrayoftrue/false),0)
will pick out the position of the first match in that array.





Jim Berglund wrote:

I don't understand the following line of code.
"=MID(R[0]C[-2],INDEX(FIND({""(403"",""(587""},R[0]C[-2]),MATCH(TRUE,ISNUMBER(FIND({""(403"",""(587""},R[0]C[-2])),0)),14)"

1. Why and when should square brackets be used?
2. Why & where should curved brackets be used?
3. Why are there double sets of quotation marks around the (403 and (587
4. I've never used the R[0]C[-2] nomenclature. Is this example designating a
cell location that is on the same row bur two columns left?
5. I can't find reference to MATCH(TRUE,ISNUMBER. What is this doing?

Thanks to anyone that takes the time to answer this.

Jim Berglund


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default General Question on one line of code - parentheses and quotation marks

Thanks, Dave - enlightening!
How about the curly brackets? { } When/Why are they used?
Jim

"Dave Peterson" wrote in message
...
#1. When you're typing a formula into a cell in excel, you can use a
formula
like this into C1:
=a1+b1
when the column headers are letters.

If the column headers are numbers, then the formula in C1 would be:
=RC[-2]+RC[-1]

The different style for those cell references for the way you type the
formula
is determined by this setting:

Tools|Options|General Tab|Check or uncheck R1C1 Reference style.

The =a1+b1 formula is in A1 reference style.
The =rc[-2]+rc[-2] is in R1C1 reference style.

========
But you can write code in the VBE for your macro that uses either
reference
style (but not a mixture).

You'd use:

activesheet.range("c1").formula = "=a1+b1"
activesheet.range("c1").formulaR1C1 = "=RC[-2]+RC[-1]"

When the macro runs, excel will plop the formula into the cell. But it'll
be
displayed in the formula by that setting (R1C1 reference style). You and
your
code don't need to worry about the setting.

Your expression was written as a .formulaR1C1 string.

The R[0]C[-2] portion says:
Stay on the same row (0 in those []'s) as the cell with the formula.
But use the cell two columns to the left (-2 in the []'s).

The cell that would be used depends on what cell the formula gets plopped
into.

You can add some test formulas to a worksheet and toggle this R1C1
reference
style setting to see how your formulas get converted from one reference
style to
the other.

#2. Those ()'s are required for some functions and other times, they're
used to
make the meaning of the expression less ambiguous to the human eye.

=sum(a1:a10)
requires the ()'s.

=a1+b1/c2*d3
doesn't need any ()'s
but I would find this easier to understand:
=a1+((b1/c2)*d3))

I wouldn't need to worry about what was intended and how excel will use
its
order of operator precedence to determine the result.

#3. When you build a string expression in code and that string includes
double
quotes, you have to double them up.

#4. Yep.

#5. the =find(...), is going to result in either a number (if it's found)
or an
error if it's not found. The expression used will result in an array of
those
numbers/errors.

So =isnumber(find(...)) will result in True's if it was found or false if
it
wasn't. (Errors are not numbers.) The expression used will result in an
array
of those True/False values.

=match(true,(thatarrayoftrue/false),0)
will pick out the position of the first match in that array.





Jim Berglund wrote:

I don't understand the following line of code.

"=MID(R[0]C[-2],INDEX(FIND({""(403"",""(587""},R[0]C[-2]),MATCH(TRUE,ISNUMBER(FIND({""(403"",""(587""},R[0]C[-2])),0)),14)"

1. Why and when should square brackets be used?
2. Why & where should curved brackets be used?
3. Why are there double sets of quotation marks around the (403 and (587
4. I've never used the R[0]C[-2] nomenclature. Is this example
designating a
cell location that is on the same row bur two columns left?
5. I can't find reference to MATCH(TRUE,ISNUMBER. What is this doing?

Thanks to anyone that takes the time to answer this.

Jim Berglund


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default General Question on one line of code - parentheses and quotationmarks

Ah, that's what you meant by curved brackets???

These are used to show that you're processing a constant array.

{"a","b","C"}
is a 3 element array of constants.

You can use them in formulas that you type instead of putting the values in a
range of cells.

They are also used by excel to indicate that the formula is an array formula.
In this case, you don't actually type the {}'s, you use ctrl-shift-enter to
enter the formula. Excel will wrap the formula with those {}'s.

If you want to learn more about these array formulas:

Bob Phillips explains =sumproduct() in much more detail he
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

And Chip Pearson has notes he
http://www.cpearson.com/excel/ArrayFormulas.aspx



Jim Berglund wrote:

Thanks, Dave - enlightening!
How about the curly brackets? { } When/Why are they used?
Jim

"Dave Peterson" wrote in message
...
#1. When you're typing a formula into a cell in excel, you can use a
formula
like this into C1:
=a1+b1
when the column headers are letters.

If the column headers are numbers, then the formula in C1 would be:
=RC[-2]+RC[-1]

The different style for those cell references for the way you type the
formula
is determined by this setting:

Tools|Options|General Tab|Check or uncheck R1C1 Reference style.

The =a1+b1 formula is in A1 reference style.
The =rc[-2]+rc[-2] is in R1C1 reference style.

========
But you can write code in the VBE for your macro that uses either
reference
style (but not a mixture).

You'd use:

activesheet.range("c1").formula = "=a1+b1"
activesheet.range("c1").formulaR1C1 = "=RC[-2]+RC[-1]"

When the macro runs, excel will plop the formula into the cell. But it'll
be
displayed in the formula by that setting (R1C1 reference style). You and
your
code don't need to worry about the setting.

Your expression was written as a .formulaR1C1 string.

The R[0]C[-2] portion says:
Stay on the same row (0 in those []'s) as the cell with the formula.
But use the cell two columns to the left (-2 in the []'s).

The cell that would be used depends on what cell the formula gets plopped
into.

You can add some test formulas to a worksheet and toggle this R1C1
reference
style setting to see how your formulas get converted from one reference
style to
the other.

#2. Those ()'s are required for some functions and other times, they're
used to
make the meaning of the expression less ambiguous to the human eye.

=sum(a1:a10)
requires the ()'s.

=a1+b1/c2*d3
doesn't need any ()'s
but I would find this easier to understand:
=a1+((b1/c2)*d3))

I wouldn't need to worry about what was intended and how excel will use
its
order of operator precedence to determine the result.

#3. When you build a string expression in code and that string includes
double
quotes, you have to double them up.

#4. Yep.

#5. the =find(...), is going to result in either a number (if it's found)
or an
error if it's not found. The expression used will result in an array of
those
numbers/errors.

So =isnumber(find(...)) will result in True's if it was found or false if
it
wasn't. (Errors are not numbers.) The expression used will result in an
array
of those True/False values.

=match(true,(thatarrayoftrue/false),0)
will pick out the position of the first match in that array.





Jim Berglund wrote:

I don't understand the following line of code.

"=MID(R[0]C[-2],INDEX(FIND({""(403"",""(587""},R[0]C[-2]),MATCH(TRUE,ISNUMBER(FIND({""(403"",""(587""},R[0]C[-2])),0)),14)"

1. Why and when should square brackets be used?
2. Why & where should curved brackets be used?
3. Why are there double sets of quotation marks around the (403 and (587
4. I've never used the R[0]C[-2] nomenclature. Is this example
designating a
cell location that is on the same row bur two columns left?
5. I can't find reference to MATCH(TRUE,ISNUMBER. What is this doing?

Thanks to anyone that takes the time to answer this.

Jim Berglund


--

Dave Peterson


--

Dave Peterson
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
Adding quotation marks to each line of cell contents with carriagereturns Will[_15_] Excel Programming 3 July 22nd 09 12:56 PM
Quotation Marks Brettjg Excel Programming 7 February 23rd 09 01:01 PM
Quotation Marks 9pluck9 Excel Discussion (Misc queries) 2 May 2nd 07 04:40 PM
Quotation marks and variables within code Pablo Excel Programming 1 October 25th 06 10:52 PM
Quotation Marks kosecki Excel Programming 3 August 31st 05 02:23 PM


All times are GMT +1. The time now is 03:09 AM.

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"