[mso] Re: Sum of Alternate Raw & Columns

  • From: "David Grugeon" <david@xxxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Thu, 2 Dec 2010 14:42:12 +1000

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@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: