Countif function

SanFranz

New Member
Joined
Apr 28, 2023
Messages
18
Office Version
  1. 2007
Hi All,
Could you please suggest how can I amend this formula whereby I can replace the part of countif(I10:I11:I13:I14:I16:I17:I18:I19:I20:I21:I28 as I would consider those as single cells rather than a series? In fact the cells in between the selection e.g. I12,I15 still applies the countif function and they shouldn't. In fact, if I replace the : with , the formula has too many conditions and I get stuck

=IF(SUM(L9:L21)*100+IF(SUM(COUNTIF(I10:I11:I13:I14:I16:I17:I18:I19:I20:I21:I28,'FATF Feb23'!B5:B17)),48,0)>48,48,((SUM(L9:L21)*100)))
 
1. restricted countries if exist in column e backgroundcolor yellow then G21 = 100
2. restricted countries if exist in column e backgroundcolor blue then G21 total all column F

Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredGermain2%
10GermainManagedSpain5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%
Sheet1


How about this condition? it will total column F because the first restricted countries is in background blue?
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
1. restricted countries if exist in column e backgroundcolor yellow then G21 = 100
2. restricted countries if exist in column e backgroundcolor blue then G21 total all column F

Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredGermain2%
10GermainManagedSpain5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%
Sheet1


How about this condition? it will total column F because the first restricted countries is in background blue?
yes exactly so if the restricted countries appears in the blue cells column F counts normally. If the restricted countries appears in the yellow will give automatically 100 in G21
 
Upvote 0
Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredSerbia2%
10GermainManagedfrance5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%100
Sheet1


Right Click Sheet1 -> view code, and then paste the code below

VBA Code:
Sub test2()

Dim dict As New dictionary
dict.CompareMode = vbTextCompare

 [g:g].Value = ""
a = Range("a9:a" & Cells(Rows.Count, "A").End(xlUp).Row)

'Create an array then put into dictionary
For i = 1 To UBound(a, 1)
    dict.Add a(i, 1), ""
Next i

'Loop through Dynamic Column E
For Each ss In Range("e9:e" & Cells(Rows.Count, "E").End(xlUp).Row)
        If dict.Exists(ss.Value) Then
            If ss.Interior.Color = 9851953 Then 'Condition if background color is blue
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row) = Application.WorksheetFunction.Sum(Range("f:F"))
                Exit For
            ElseIf ss.Interior.Color = 65535 Then 'Condition if background color is yellow
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row).Value = 100
                Exit For
            End If
        End If
Next ss

End Sub

How about if the restricted countries not in either yellow background color or blue background color column?
 
Last edited:
Upvote 0
Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredSerbia2%
10GermainManagedfrance5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%100
Sheet1


Right Click Sheet1 -> view code, and then paste the code below

VBA Code:
Sub test2()

Dim dict As New dictionary
dict.CompareMode = vbTextCompare

 [g:g].Value = ""
a = Range("a9:a" & Cells(Rows.Count, "A").End(xlUp).Row)

'Create an array then put into dictionary
For i = 1 To UBound(a, 1)
    dict.Add a(i, 1), ""
Next i

'Loop through Dynamic Column E
For Each ss In Range("e9:e" & Cells(Rows.Count, "E").End(xlUp).Row)
        If dict.Exists(ss.Value) Then
            If ss.Interior.Color = 9851953 Then 'Condition if background color is blue
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row) = Application.WorksheetFunction.Sum(Range("f:F"))
                Exit For
            ElseIf ss.Interior.Color = 65535 Then 'Condition if background color is yellow
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row).Value = 100
                Exit For
            End If
        End If
Next ss

End Sub

How about if the restricted countries not in either yellow background color or blue background color column?
Countries are in column E anyway. Could you please provide the excel formula as I use the spreadsheet and not vba
Thanks
 
Upvote 0
Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredSerbia2%
10GermainManagedfrance5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%100
Sheet1


Right Click Sheet1 -> view code, and then paste the code below

VBA Code:
Sub test2()

Dim dict As New dictionary
dict.CompareMode = vbTextCompare

 [g:g].Value = ""
a = Range("a9:a" & Cells(Rows.Count, "A").End(xlUp).Row)

'Create an array then put into dictionary
For i = 1 To UBound(a, 1)
    dict.Add a(i, 1), ""
Next i

'Loop through Dynamic Column E
For Each ss In Range("e9:e" & Cells(Rows.Count, "E").End(xlUp).Row)
        If dict.Exists(ss.Value) Then
            If ss.Interior.Color = 9851953 Then 'Condition if background color is blue
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row) = Application.WorksheetFunction.Sum(Range("f:F"))
                Exit For
            ElseIf ss.Interior.Color = 65535 Then 'Condition if background color is yellow
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row).Value = 100
                Exit For
            End If
        End If
Next ss

End Sub

How about if the restricted countries not in either yellow background color or blue background color column?
it remains the normal count
 
Upvote 0
it remains the normal count
1. restricted countries if exist in column e backgroundcolor yellow then G21 = 100

this one 100 because e10 is france (restricted country) and in backgroundcolor yellow that's why output: 100

the code will start run from e9 to bottom, if found restricted country then will check the backgroundcolor (if yellow then 100, if blue then calculate all)

May i know what's the answer from this case? maybe im misunderstanding
 
Upvote 0
Book2
ABCDEFG
7Restricted Countries
8List Country
9SpainRegisteredSerbia2%
10GermainManagedfrance5%
11FranceOperatingAustrali4%
12UBO NationalityGibraltar6%
13UBO ResidenceyUSA2%
14Jurisdiction7%
15LicensedAndorra2%
16Top 3 countriesCile3%
17UK7%
18Malta1%
19Top 3 countries to payCanada2%
20Russia8%
21Serbia1%100
Sheet1


Right Click Sheet1 -> view code, and then paste the code below

VBA Code:
Sub test2()

Dim dict As New dictionary
dict.CompareMode = vbTextCompare

 [g:g].Value = ""
a = Range("a9:a" & Cells(Rows.Count, "A").End(xlUp).Row)

'Create an array then put into dictionary
For i = 1 To UBound(a, 1)
    dict.Add a(i, 1), ""
Next i

'Loop through Dynamic Column E
For Each ss In Range("e9:e" & Cells(Rows.Count, "E").End(xlUp).Row)
        If dict.Exists(ss.Value) Then
            If ss.Interior.Color = 9851953 Then 'Condition if background color is blue
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row) = Application.WorksheetFunction.Sum(Range("f:F"))
                Exit For
            ElseIf ss.Interior.Color = 65535 Then 'Condition if background color is yellow
                Range("g" & Cells(Rows.Count, "E").End(xlUp).Row).Value = 100
                Exit For
            End If
        End If
Next ss

End Sub

How about if the restricted countries not in either yellow background color or blue background color column?
please do you have the excel formula? I'm not able to convert the VBA one
Thank you!
 
Upvote 0
1. restricted countries if exist in column e backgroundcolor yellow then G21 = 100

this one 100 because e10 is france (restricted country) and in backgroundcolor yellow that's why output: 100

May i know what's the answer from this case? maybe im misunderstanding
no 100 is the score that automatically should appears in G21 without any sum
 
Upvote 0
please do you have the excel formula? I'm not able to convert the VBA one
Thank you!

maybe need to wait other excel experts for formula, sorry since i can only provide through VBA code :(
 
Upvote 0

Forum statistics

Threads
1,223,792
Messages
6,174,611
Members
452,574
Latest member
hang_and_bang

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