Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sum cells that have no formula

Posted on 2014-09-10
7
Medium Priority
?
201 Views
Last Modified: 2014-09-11
Hello,
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?
0
Comment
Question by:acdecal
[X]
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
7 Comments
 
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....

or

if not myCell.HasFormula then....
0
 

Author Comment

by:acdecal
ID: 40315632
Is there a non VBA function I can use in a SUMIF ?
0
 
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.
0
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!

 

Author Comment

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

Accepted Solution

by:
Ken Butters earned 2000 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:

=sumIfNoFormula(AB10:AQ10)

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
    Next
End Function

Open in new window

0
 
LVL 4

Expert Comment

by:rlarian
ID: 40315900
change your formula to make the resulting figure text instead of a number.
=TEXT([formula],"#,###.00")
sum won't add text fields.
0
 

Author Closing Comment

by:acdecal
ID: 40316727
That did the trick!  Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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,…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

722 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