Solved

Sum cells that have no formula

Posted on 2014-09-10
7
189 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

=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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now