PC Review


Reply
Thread Tools Rate Thread

How can I use this expression "=SUM(RC[a0]:RC[a1])" work in Excel

 
 
funmi_Bash
Guest
Posts: n/a
 
      12th Dec 2009
I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
values a0 and a1 are variables.
How can this be done? Please assist and advice.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      12th Dec 2009
dim s0 as string 'I'd use long's
dim s1 as string

s0 = "3"
s1 = "6"

somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"

funmi_Bash wrote:
>
> I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> values a0 and a1 are variables.
> How can this be done? Please assist and advice.


--

Dave Peterson
 
Reply With Quote
 
funmi_Bash
Guest
Posts: n/a
 
      12th Dec 2009
Dave,
I would just like to say a very BIG 'Thank You" for this post.

Here's the working implementation for the benefit of everyone:

Range(Cells(5, 9), Cells(5, 9)).Formula = "=SUM(RC[" & a0 & "]:RC[" & a1
& "])"

Thanks again, Dave!

"Dave Peterson" wrote:

> dim s0 as string 'I'd use long's
> dim s1 as string
>
> s0 = "3"
> s1 = "6"
>
> somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"
>
> funmi_Bash wrote:
> >
> > I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> > values a0 and a1 are variables.
> > How can this be done? Please assist and advice.

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      13th Dec 2009
First, since you're using the formula in R1C1 reference style, you should be
using .FormulaR1C1.

Second,

Range(Cells(5, 9), Cells(5, 9))

represents a single cell.

You could either use:

cells(5,9).formulaR1C1 = ...
or even
range("I5").formular1c1 = ....



funmi_Bash wrote:
>
> Dave,
> I would just like to say a very BIG 'Thank You" for this post.
>
> Here's the working implementation for the benefit of everyone:
>
> Range(Cells(5, 9), Cells(5, 9)).Formula = "=SUM(RC[" & a0 & "]:RC[" & a1
> & "])"
>
> Thanks again, Dave!
>
> "Dave Peterson" wrote:
>
> > dim s0 as string 'I'd use long's
> > dim s1 as string
> >
> > s0 = "3"
> > s1 = "6"
> >
> > somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"
> >
> > funmi_Bash wrote:
> > >
> > > I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> > > values a0 and a1 are variables.
> > > How can this be done? Please assist and advice.

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
funmi_Bash
Guest
Posts: n/a
 
      13th Dec 2009
Hello Dave!

I felt constrained to use the R1C1-reference style because the range style
did not give me the expected result, namely:
Range(Cells(5, 4 + 5), Cells(5, 4 + 5)).Formula = "=Sum(Range[Cells(5,
4), Cells(5, 4 + 5)])" does not work.

Had this worked, it would've been so much easier to just substitute the
figures with the appropriate algebraic variables/expressions.

"Dave Peterson" wrote:

> First, since you're using the formula in R1C1 reference style, you should be
> using .FormulaR1C1.
>
> Second,
>
> Range(Cells(5, 9), Cells(5, 9))
>
> represents a single cell.
>
> You could either use:
>
> cells(5,9).formulaR1C1 = ...
> or even
> range("I5").formular1c1 = ....
>
>
>
> funmi_Bash wrote:
> >
> > Dave,
> > I would just like to say a very BIG 'Thank You" for this post.
> >
> > Here's the working implementation for the benefit of everyone:
> >
> > Range(Cells(5, 9), Cells(5, 9)).Formula = "=SUM(RC[" & a0 & "]:RC[" & a1
> > & "])"
> >
> > Thanks again, Dave!
> >
> > "Dave Peterson" wrote:
> >
> > > dim s0 as string 'I'd use long's
> > > dim s1 as string
> > >
> > > s0 = "3"
> > > s1 = "6"
> > >
> > > somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"
> > >
> > > funmi_Bash wrote:
> > > >
> > > > I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> > > > values a0 and a1 are variables.
> > > > How can this be done? Please assist and advice.
> > >
> > > --
> > >
> > > Dave Peterson
> > > .
> > >

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      13th Dec 2009
The point that I was trying to make was concerning the lefthand side of your
expression.

..formula should have been .formular1c1

And that this expression is too complex to refer to a single cell:
Range(Cells(5, 4 + 5), Cells(5, 4 + 5))


======
But to address your (new) point about using .formula, you could change the
expression to:

Cells(5, 4 + 5).Formula _
= "=sum(" & Range(Cells(5, 4), Cells(5, 4 + 4)).Address & ")"

Notice that I used .Formula (not .formular1c1).

..Address will return the A1 reference style address (with absolute columns and
rows)--like: $D$5:$H$5

There are options that you can use to eliminated the $ if you wanted.

I also had to change the ending cell to avoid a circular reference.

=====
But there are times when using R1C1 reference style (along with the .formular1c1
property) makes life much easier. This looks like it would be one of those
times.



funmi_Bash wrote:
>
> Hello Dave!
>
> I felt constrained to use the R1C1-reference style because the range style
> did not give me the expected result, namely:
> Range(Cells(5, 4 + 5), Cells(5, 4 + 5)).Formula = "=Sum(Range[Cells(5,
> 4), Cells(5, 4 + 5)])" does not work.
>
> Had this worked, it would've been so much easier to just substitute the
> figures with the appropriate algebraic variables/expressions.
>
> "Dave Peterson" wrote:
>
> > First, since you're using the formula in R1C1 reference style, you should be
> > using .FormulaR1C1.
> >
> > Second,
> >
> > Range(Cells(5, 9), Cells(5, 9))
> >
> > represents a single cell.
> >
> > You could either use:
> >
> > cells(5,9).formulaR1C1 = ...
> > or even
> > range("I5").formular1c1 = ....
> >
> >
> >
> > funmi_Bash wrote:
> > >
> > > Dave,
> > > I would just like to say a very BIG 'Thank You" for this post.
> > >
> > > Here's the working implementation for the benefit of everyone:
> > >
> > > Range(Cells(5, 9), Cells(5, 9)).Formula = "=SUM(RC[" & a0 & "]:RC[" & a1
> > > & "])"
> > >
> > > Thanks again, Dave!
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > dim s0 as string 'I'd use long's
> > > > dim s1 as string
> > > >
> > > > s0 = "3"
> > > > s1 = "6"
> > > >
> > > > somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"
> > > >
> > > > funmi_Bash wrote:
> > > > >
> > > > > I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> > > > > values a0 and a1 are variables.
> > > > > How can this be done? Please assist and advice.
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > > .
> > > >

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
funmi_Bash
Guest
Posts: n/a
 
      13th Dec 2009
Thanks again Dave!

What can I say? Beauty, eh?

God bless you my man! Real Good!!

"Dave Peterson" wrote:

> The point that I was trying to make was concerning the lefthand side of your
> expression.
>
> ..formula should have been .formular1c1
>
> And that this expression is too complex to refer to a single cell:
> Range(Cells(5, 4 + 5), Cells(5, 4 + 5))
>
>
> ======
> But to address your (new) point about using .formula, you could change the
> expression to:
>
> Cells(5, 4 + 5).Formula _
> = "=sum(" & Range(Cells(5, 4), Cells(5, 4 + 4)).Address & ")"
>
> Notice that I used .Formula (not .formular1c1).
>
> ..Address will return the A1 reference style address (with absolute columns and
> rows)--like: $D$5:$H$5
>
> There are options that you can use to eliminated the $ if you wanted.
>
> I also had to change the ending cell to avoid a circular reference.
>
> =====
> But there are times when using R1C1 reference style (along with the .formular1c1
> property) makes life much easier. This looks like it would be one of those
> times.
>
>
>
> funmi_Bash wrote:
> >
> > Hello Dave!
> >
> > I felt constrained to use the R1C1-reference style because the range style
> > did not give me the expected result, namely:
> > Range(Cells(5, 4 + 5), Cells(5, 4 + 5)).Formula = "=Sum(Range[Cells(5,
> > 4), Cells(5, 4 + 5)])" does not work.
> >
> > Had this worked, it would've been so much easier to just substitute the
> > figures with the appropriate algebraic variables/expressions.
> >
> > "Dave Peterson" wrote:
> >
> > > First, since you're using the formula in R1C1 reference style, you should be
> > > using .FormulaR1C1.
> > >
> > > Second,
> > >
> > > Range(Cells(5, 9), Cells(5, 9))
> > >
> > > represents a single cell.
> > >
> > > You could either use:
> > >
> > > cells(5,9).formulaR1C1 = ...
> > > or even
> > > range("I5").formular1c1 = ....
> > >
> > >
> > >
> > > funmi_Bash wrote:
> > > >
> > > > Dave,
> > > > I would just like to say a very BIG 'Thank You" for this post.
> > > >
> > > > Here's the working implementation for the benefit of everyone:
> > > >
> > > > Range(Cells(5, 9), Cells(5, 9)).Formula = "=SUM(RC[" & a0 & "]:RC[" & a1
> > > > & "])"
> > > >
> > > > Thanks again, Dave!
> > > >
> > > > "Dave Peterson" wrote:
> > > >
> > > > > dim s0 as string 'I'd use long's
> > > > > dim s1 as string
> > > > >
> > > > > s0 = "3"
> > > > > s1 = "6"
> > > > >
> > > > > somecell.formular1c1 = "=SUM(RC[" & s0 & "]:RC[" & s1 & "])"
> > > > >
> > > > > funmi_Bash wrote:
> > > > > >
> > > > > > I need to insert this formula "=SUM(RC[s0$]:RC[s1$])" in a cell such that the
> > > > > > values a0 and a1 are variables.
> > > > > > How can this be done? Please assist and advice.
> > > > >
> > > > > --
> > > > >
> > > > > Dave Peterson
> > > > > .
> > > > >
> > >
> > > --
> > >
> > > Dave Peterson
> > > .
> > >

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Report "Control Source" Build Expression Box doesn't work/works DogmaDot Microsoft Access 1 3rd Sep 2009 05:51 PM
ReVIEW (Erratum): some shortcut keys not working anymore-----help""""""""PhpApach...WORK WELL!!!! wbrowse@gmail.com Windows XP Help 0 13th Apr 2007 12:29 PM
"Find" expression won't work Harold Good Microsoft Excel Programming 3 28th Jul 2006 12:16 PM
Why doesnt this expression work =Format(Date(), "dd-mmm-yyyy" =?Utf-8?B?U3RlaW5lcg==?= Microsoft Access Forms 1 27th Jun 2005 10:17 AM
REQ: Need Criteria expression that will ask for "from" and "to" dates and then select records that fall within that date span for access 2000 Please...TIA Ralph Malph Microsoft Access Queries 2 18th Apr 2005 05:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:40 PM.