Sep 09 2020 08:45 AM - edited Sep 09 2020 10:17 AM
I have a list of bond payments. The ones that come in on the first of the month are in font size 10....the ones that pay on the 15th are in font size 12. Is there a way for me to create a formula that will add the values of only one particular font size? Thanks for any help.
Sep 09 2020 10:52 AM
Hi @KevinG44,
You can use the following VBA code.
Private Sub count_font()
Dim i As Integer
Dim calc15 As Integer
Dim font15 As Integer
Dim j As Integer
Dim calc10 As Integer
Dim font10 As Integer
calc = 0
'loops through the cells in column 1
For i = 1 To 8
'gets the font size
font15 = Range(Cells(i, 1), _
Cells(i, 1)).Font.Size
If font15 = 15 Then
calc15 = calc15 + Cells(i, 1).Value
End If
Next i
Cells(2, 3) = "Total for Font 15 - " & calc15
calc10 = 0
'loops through the cells in column 1
For j = 1 To 8
'gets the font size
font10 = Range(Cells(j, 1), _
Cells(j, 1)).Font.Size
If font10 = 10 Then
calc10 = calc10 + Cells(j, 1).Value
End If
Next j
Cells(3, 3) = "Total for Font 10 - " & calc10
End Sub
You will need to adjust it for where your data is actually written in your spreadsheet and where you want the output to go. Let me know if you need a hand with that.
Sep 09 2020 11:01 AM