Sum cells that have no formula

Posted on 2014-09-10
Last Modified: 2014-09-11
I have data in a ranges (rows) where the cells in the range contain a formula for forecasting.  Users are to overwrite the formula when actual figures are known and I have conditional formatting to highlight the cell.  I would like a formula to sum the actual numbers entered for each row and not include the cells with formulas.  I tried defining a VBA function to test for cell color but it will not pick up conditional formatting changes.

Any help on this please?
Question by:acdecal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 19

Expert Comment

by:Ken Butters
ID: 40315626
Since the cell is going to be updated to no longer contain a formula...

I would suggest that you just test for the existence of a forumla...

Dim myCell as range

if myCell.HasFormula then....


if not myCell.HasFormula then....

Author Comment

ID: 40315632
Is there a non VBA function I can use in a SUMIF ?
LVL 19

Expert Comment

by:Ken Butters
ID: 40315697
I don't believe there is a built in one...

but thinking you could use define it like this in vba:

Function containsFormula(aCellRange As Range) 
    containsFormula = aCellRange.HasFormula 
End Function

Open in new window

Then use =containsFormula in your worksheet or in your sumif function.
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.


Author Comment

ID: 40315743
I tried =SUMIF(AB10:AQ10,ContainsFormula(AB10:AQ10))  but not working.  Any thoughts?
LVL 19

Accepted Solution

Ken Butters earned 500 total points
ID: 40315822
You are right sumif... doesn't like that for the criteria....

I tried this... this seemed to do what you are asking:

After adding this vba code... then in your sheet you can use it like this:


it will include in the sum... any of the cells that do NOT contain a formula.

Function sumIfNoFormula(aCellRange As Range)
    Dim aCell As Range
    sumIfNoFormula = 0
    For Each aCell In aCellRange
        If Not aCell.HasFormula Then
            sumIfNoFormula = sumIfNoFormula + aCell.Value
        End If
End Function

Open in new window


Expert Comment

ID: 40315900
change your formula to make the resulting figure text instead of a number.
sum won't add text fields.

Author Closing Comment

ID: 40316727
That did the trick!  Thanks

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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…

710 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