[mso] Re: Sum of Alternate Raw & Columns

  • From: "David Grugeon" <david@xxxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Thu, 2 Dec 2010 16:45:30 +1000

OK.  I will tell you how to do it with a formula.

Let us assume you want to add up the values in the even cells in the range
D3:D120.

In an unused Column (I will assume it is Column B) put the formula
=MOD(Row(),2).  This will result in the column being filled with
alternatively 1 and 0.  You can hide the column.

Now you can put a formula =Sumif(B3:B120,0,D3:D120)

If you want the values in odd cells change the 0 in the formula to 1

Best regards
David Grugeon
M-0429 029 836
P-(07)3263 7786


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On
> Behalf Of PrIyAnKa
> Sent: Thursday, 2 December 2010 3:06 PM
> To: mso@xxxxxxxxxxxxx
> Subject: [mso] Re: Sum of Alternate Raw & Columns
> 
> I do not need any VBA code for that ,i req a formula for that REgards
Priyanka
> 
> On Thu, Dec 2, 2010 at 10:12 AM, David Grugeon <david@xxxxxxxxxxxxxx>
> wrote:
> 
> > Here are four functions.  Add a module to your workbook and paste
> > these into the module.  You can then use them in your worksheet as you
> > would with built-in functions.  Just type in =sumOddRows(A1:A47) or
> > whatever.
> >
> > The main issue with user functions is that occasionally you have to
> > make them recalculate manually by selecting them and pressing F9.
> > They are OK if you change the referenced cells manually but there is
> > an issue if the referenced cells are changed by code.
> >
> >
> > [code]
> > Option Explicit
> >
> > Function sumOddRows(r As Range)
> > Dim c As Range
> > Dim T As Double
> > For Each c In r
> > If c.Row Mod 2 = 1 Then
> > T = T + c.Value
> > End If
> > Next c
> > sumOddRows = T
> > End Function
> >
> > Function sumEvenRows(r As Range)
> > Dim c As Range
> > Dim T As Double
> > For Each c In r
> > If c.Row Mod 2 = 0 Then
> > T = T + c.Value
> > End If
> > Next c
> > sumOddRows = T
> > End Function
> >
> > Function sumOddCols(r As Range)
> > Dim c As Range
> > Dim T As Double
> > For Each c In r
> > If c.Column Mod 2 = 1 Then
> > T = T + c.Value
> > End If
> > Next c
> > sumOddRows = T
> > End Function
> >
> > Function sumEvenCols(r As Range)
> > Dim c As Range
> > Dim T As Double
> > For Each c In r
> > If c.Column Mod 2 = 0 Then
> > T = T + c.Value
> > End If
> > Next c
> > sumOddRows = T
> > End Function
> > [/code]
> >
> > Best regards
> > David Grugeon
> > M-0429 029 836
> > P-(07)3263 7786
> >
> > > -----Original Message-----
> > > From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On
> > > Behalf Of PrIyAnKa
> > > Sent: Monday, 29 November 2010 9:41 PM
> > > To: mso@xxxxxxxxxxxxx
> > > Subject: [mso] Sum of Alternate Raw & Columns
> > >
> > > Dear Team
> > > Kidnly help me as I m trying to making sum of alternate raws &
> > > columns,
> > >
> > > KIndly help me for some easy formula as =NPV(.................)
> > > becomes
> > heavy
> > >
> > > E.G. sum of A1+C1+E1+G1 (Alternate Columns)
> > >         sum of A1+A3+A5+A7 (Altername Raws)
> > >
> > > REgards
> > > PRiyanka
> > >
> > >
> > >
> **********************************************************
> > > ***
> > > You are receiving this mail because you subscribed to
> > > mso@xxxxxxxxxxxxxxx MicrosoftOffice@xxxxxxxxxxxxxxxx
> > >
> > > To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> > >
> > > To Unsubscribe from this group, visit the group's homepage and use
> > > the dropdown menu at the top.  This will allow you to unsubscribe
> > > your email address or change your email settings to digest or vacation
(no
> mail).
> > > //www.freelists.org/webpage/mso
> > >
> > > To be able to share files with the group, you must join our Yahoo
> > > sister group.  This group will not allow for posting of emails, but
> > > will allow
> > you to
> > > join and share problem files, templates, etc.:
> > > http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is
> > > for
> > FILE
> > > SHARING ONLY.
> > >
> > > If you are using Outlook and you see a lot of unnecessary code in
> > > your
> > email
> > > messages, read these instructions that explain why and how to fix it:
> > > http://personal-computer-tutor.com/abc3/v28/greg28.htm
> > >
> **********************************************************
> > > ***
> >
> >
> **********************************************************
> ***
> > You are receiving this mail because you subscribed to
> > mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx
> >
> > To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> >
> > To Unsubscribe from this group, visit the group's homepage and use the
> > dropdown menu at the top.  This will allow you to unsubscribe your
> > email address or change your email settings to digest or vacation (no
mail).
> > //www.freelists.org/webpage/mso
> >
> > To be able to share files with the group, you must join our Yahoo
> > sister group.  This group will not allow for posting of emails, but
> > will allow you to join and share problem files, templates, etc.:
> > http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for
> > FILE SHARING ONLY.
> >
> > If you are using Outlook and you see a lot of unnecessary code in your
> > email messages, read these instructions that explain why and how to fix
it:
> > http://personal-computer-tutor.com/abc3/v28/greg28.htm
> >
> **********************************************************
> ***
> >
> 
> 
> **********************************************************
> ***
> You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
> MicrosoftOffice@xxxxxxxxxxxxxxxx
> 
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> 
> To Unsubscribe from this group, visit the group's homepage and use the
> dropdown menu at the top.  This will allow you to unsubscribe your email
> address or change your email settings to digest or vacation (no mail).
> //www.freelists.org/webpage/mso
> 
> To be able to share files with the group, you must join our Yahoo sister
> group.  This group will not allow for posting of emails, but will allow
you to
> join and share problem files, templates, etc.:
> http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for
FILE
> SHARING ONLY.
> 
> If you are using Outlook and you see a lot of unnecessary code in your
email
> messages, read these instructions that explain why and how to fix it:
> http://personal-computer-tutor.com/abc3/v28/greg28.htm
> **********************************************************
> ***

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: