Solved

Subtotal Ignoring error

Posted on 2011-03-15
6
554 Views
Last Modified: 2012-05-11
I need to subtotal a column ignoring NA# Values in VBA
I am currently using  ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[3]C:R[7128]C)"
I tried to use Iserror and ISNA , but receiving error. Please help!
0
Comment
Question by:Ruchi_Sas
6 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35136724
Try:
activecell.FormulaArray = "=SUM(IF(SUBTOTAL(2,OFFSET(R[3]C:R[7128]C,ROW(R[3]C:R[7128]C)-MIN(ROW(R[3]C:R[7128]C)),,1)),R[3]C:R[7128]C,0))"

Open in new window


0
 
LVL 6

Accepted Solution

by:
akajohn earned 125 total points
ID: 35136733
Try

=SUMIF(9,R[3]C:R[7128]C,"<>#N/A")
0
 
LVL 19

Expert Comment

by:akoster
ID: 35136761
you could try using matrix formulae, this way you could use the ISNA function :

=SUM(IF(ISNA(A1:A6); 0; A1:A6))

Open in new window


a formula is turned into a matrix formula by pressing [Ctrl]-[Shift]-[Enter] instead of just [Enter] when typing the formula.
When clicking on a cell containing a matrix formula, the formula itself is presented with enclosing { } brackets
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 19

Expert Comment

by:akoster
ID: 35136764
then replace A1:A6 with R[3]C:R[7128]C
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35136796
Which version of Excel are you using? In Excel 2010 you can use AGGREGATE function to subtotal and ignore errors, e.g.

=AGGREGATE(9,3,A1:A10)

regards, barry
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35136797
Note: I assumed you were using Subtotal in order to allow filtering. If that is not the case, then you could just use:

ActiveCell.FormulaR1C1 = "=SUMIF(R[3]C:R[7128]C,""<>#N/A"")"

which is basically a correction of what akajohn said.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question