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:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
the code i found is this but its just sum if bold but i want with condition value if true and false

Code:
Function SumIfBold(MyRange As Range) As Double

    Dim cell As Range
    For Each cell In MyRange
        If cell.Font.Bold = True Then
            SumIfBold = SumIfBold + cell
        End If
    Next cell

End Function
 
Upvote 0
Like this?

Code:
Function SumIfBold(MyRange As Range) As Double

    Dim cell As Range
    For Each cell In MyRange
        If cell.Font.Bold And cell.Value > 3000 Then
            SumIfBold = SumIfBold + cell.Value
        End If
    Next cell

End Function
 
Upvote 0
its not working..

i want
=Sumifbold(F11:F72,IF(F11:F72>3000,3000,""))

if the range is more than 3000 then 3000.

thanks for your reply
 
Upvote 0
Try

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
 
Upvote 0
the code is working but not sum all the lower 3000.can u write somethin so the code sum all the lower than 3000 too.

somethin like this =sumifbold(f11:f72,MIN(3000,F11),F11)

thanks man.almost done now..
 
Last edited:
Upvote 0
That will sum all bold cells in the range, with a cap of 3000. If that is not what you want you need to explain in English, not pseudo code.
 
Upvote 0
i want to sum all in the range include bold but all bold cells will take 3000 only.
the last code u did.it sum only the bold.it not sum all lower than 3000.
sorry for my bad english.
 
Upvote 0
can u help me with this pls? its almost done. just need to write somethin so it will count the unbold too.thanks a lot vog
 
Upvote 0
Do you need it to sum for each number in the range, that is less than 3000 and bold or do you need it to sum for each number that is in bold in the range with the value that is in F11 with a cap of 3000?

If the latter,

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

Then write your formula like this:
=sumifbold(F11:F72,MIN(3000,F11))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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