sum if bold or italics with condition

spilner

Board Regular
Joined
Jun 7, 2011
Messages
146
hi,heres the code.

=Sumifbold(F11:F72,range>3000,3000,"value false"))

can someone write a vba for this?

thanks a lot
 
Last edited:
If the former:

Code:
Function SumIfBold(r As Range) As Double
Dim c As Range
Application.Volatile
For Each c In r
    If c.Font.Bold Then s = s + Application.WorksheetFunction.Min(3000, c)
Next
SumIfBold = s
End Function

Then write your formula like this:

=SUMIFBOLD(F12:F72)
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
in the range f11:f72 example

5000
2000
10
5
600
500
1

i want it count all in the range except the bold only will take 3000 from 5000.
the total will be 6116.
which more than >3000.i will bold it.so,it take 3000 only.the one without bold,it will sum too.
let me know if u dont understand.sorry for my bad english.
 
Upvote 0
the VOG's code is working fine.just need to add the code that will sum without the bold too.

Code:
Function SumIfBold(MyRange As Range) As Double

    Dim cell As Range
    For Each cell In MyRange
        If cell.Font.Bold Then
            SumIfBold = SumIfBold + WorksheetFunction.Min(cell.Value, 3000)
        End If
    Next cell

End Function</pre>
 
Upvote 0
Why don't you just use a regular formula then?

=SUM(IF(F11:F72>3000,3000,F11:F72))

Confirm with CTRL-SHIFT-ENTER rather than just Enter
 
Upvote 0
the reason is sometime i will count the value more than 3000.

example :

7000
5000
2000
10
5
600
500
1
-----
13116

can u write the vba code.the vog's code is almost done.just need to add it sum the unbold too.thanks VOG & PEPPER
 
Last edited:
Upvote 0
Maybe

Code:
Function SumIfBold(MyRange As Range) As Double

    Dim cell As Range
    For Each cell In MyRange
        If cell.Font.Bold Then
            SumIfBold = SumIfBold + WorksheetFunction.Min(cell.Value, 3000)
        Else
            SumIfBold = SumIfBold + cell.Value
        End If
    Next cell

End Function
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top