Tough to find the right formulas to verify these info!

hnt007

Board Regular
Joined
Dec 18, 2021
Messages
98
Office Version
  1. 365
Platform
  1. MacOS
Hi everyone!

First of all, thank you so much in advance for your help! I've been stuck for days on this....

I have a cell with:
Composer A (BMI) 50% [292650159], Composer B (ASCAP) 30% [154541151], Composer C (SESAC) 5% [55547898], Composer D (SESAC) 5% [4332233], Composer E (SOCAN) 10% [0099887]

(BMI, ASCAP, SESAC, and SOCAN are the royalty distribution companies these composers belong to, the percentages represent their shares of the song, the numbers between [ ] are their ID numbers with the royalty companies)

1)I'm trying to find a formula to put in Conditional Formatting that will highlight this cell in green if the sum of the percentages equals 100 to verify that the splits are correct

2)I have another cell with:
Publisher A (BMI) 50% [12345612], Publisher B (ASCAP) 40% [415156115], Publisher C (SESAC) 10% [4441121254]

I'm trying to find a formula to highlight this cell in green if the percentages for BMI and SESAC match the ones in the cell with the composers AND if the sum of the percentages in this cell with publishers equals 100.

(You can see that 2 composers are with SESAC, so 5%+5%, the publisher with SESAC should have 10%. All composers who are not with BMI or SESAC would be considered to be with ASCAP, that's why you don't see SOCAN in the publishers, and that's why ASCAP has 30%+10% here.)

Thanks!!!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Here's one way to do part 1

Book1
AB
1Data ColHelper Col
2Composer A (BMI) 50% [292650159], Composer B (ASCAP) 30% [154541151], Composer C (SESAC) 5% [55547898], Composer D (SESAC) 5% [4332233], Composer E (SOCAN) 10% [0099887]100
3
4
Sheet1
Cell Formulas
RangeFormula
B2B2=SumPct(A2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2Expression=$B2=100textNO


VBA Code:
'User defined function to sum the percentages
Function SumPct(DataStr As String) As Double
    Dim SA As Variant, S As String
    Dim I As Long, PctSum As Double

    SA = Split(DataStr, " ")
    For I = LBound(SA) To UBound(SA)
        S = SA(I)

        If InStr(S, "%") > 0 Then
            S = Replace(S, "%", "")
            If IsNumeric(S) Then
                PctSum = PctSum + Val(S)
            End If
        End If
    Next I
    SumPct = PctSum
End Function
 
Upvote 0
Solution
Part 2

Book1
A
1Composer Cell
2Composer A (BMI) 50% [292650159], Composer B (ASCAP) 30% [154541151], Composer C (SESAC) 5% [55547898], Composer D (SESAC) 5% [4332233], Composer E (SOCAN) 10% [0099887]
3
4Publisher Cell
5Publisher A (BMI) 50% [12345612], Publisher B (ASCAP) 40% [415156115], Publisher C (SESAC) 10% [4441121254]
6
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A5Expression=AND(SumPct($A$5)=100,BMI_SESAC($A$5)=BMI_SESAC($A$2))textNO
A2Expression=SumPct($A$2)=100textNO



VBA Code:
'User defined function to sum the BMI_SESAC percentages
Function BMI_SESAC(DataStr As String) As Double
    Dim SA As Variant, S As String
    Dim I As Long, PctSum As Double, Skip As Boolean

    SA = Split(DataStr, " ")
    For I = LBound(SA) To UBound(SA)
        S = SA(I)

        If Left(S, 1) = "(" Then
            Select Case S
            Case "(BMI)", "(SESAC)"
                Skip = False
            Case Else
                Skip = True
            End Select
        End If

        If Not Skip And InStr(S, "%") > 0 Then
            S = Replace(S, "%", "")
            If IsNumeric(S) Then
                PctSum = PctSum + Val(S)
            End If
        End If
    Next I
    BMI_SESAC = PctSum
End Function
 
Upvote 0
Part 2

Book1
A
1Composer Cell
2Composer A (BMI) 50% [292650159], Composer B (ASCAP) 30% [154541151], Composer C (SESAC) 5% [55547898], Composer D (SESAC) 5% [4332233], Composer E (SOCAN) 10% [0099887]
3
4Publisher Cell
5Publisher A (BMI) 50% [12345612], Publisher B (ASCAP) 40% [415156115], Publisher C (SESAC) 10% [4441121254]
6
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A5Expression=AND(SumPct($A$5)=100,BMI_SESAC($A$5)=BMI_SESAC($A$2))textNO
A2Expression=SumPct($A$2)=100textNO



VBA Code:
'User defined function to sum the BMI_SESAC percentages
Function BMI_SESAC(DataStr As String) As Double
    Dim SA As Variant, S As String
    Dim I As Long, PctSum As Double, Skip As Boolean

    SA = Split(DataStr, " ")
    For I = LBound(SA) To UBound(SA)
        S = SA(I)

        If Left(S, 1) = "(" Then
            Select Case S
            Case "(BMI)", "(SESAC)"
                Skip = False
            Case Else
                Skip = True
            End Select
        End If

        If Not Skip And InStr(S, "%") > 0 Then
            S = Replace(S, "%", "")
            If IsNumeric(S) Then
                PctSum = PctSum + Val(S)
            End If
        End If
    Next I
    BMI_SESAC = PctSum
End Function
Thank you sooo much for your help! Unfortunately, the SumPct doesn't work in my Excel, I'm not sure why!?
 

Attachments

  • Screen Shot 2021-12-19 at 1.46.45 PM.png
    Screen Shot 2021-12-19 at 1.46.45 PM.png
    44.8 KB · Views: 8
Upvote 0
I'm not sure either, since it works ok for me. Did you put it in a VBA code module? Function SumPct is a custom VBA function. Unless you are at least somewhat familiar with VBA, I'm not sure you will be able to benefit from this. To be available as a function in your worksheet, Function SumPct must be added to a VBA (macro) code module that you add to your workbook.

1639956894780.png
 
Upvote 0
I added the VBA codes and it's now working, thank you so much for taking the time to help me out!!
 
Upvote 0

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

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