Count & return specific value based on multiple conditions

GingaNinga

New Member
Joined
Sep 1, 2017
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello - first- thank you experts for your help.

I am having trouble articulating what I am trying to accomplish, but I will give it a shot.

I am trying to return a specific value in a column based on two conditions.

Condition 1: If the Unique Display ID is the same
Condition 2: If the sum of TL Gum Displays is greater than 1

Result: Unique Gum column would return a value of 1

Example of expected result:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Unique ID[/TD]
[TD]TL Gum[/TD]
[TD]Unique Gum[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]0[/TD]
[TD]0 or blank[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]1[/TD]
[TD]0 or blank[/TD]
[/TR]
</tbody>[/TABLE]


A few additional things - I don't care in which row the value of 1 appears for Unique Gum, and where it equals 0, I don't care if that is a 0 or a blank.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
this assumes the data is in columns A:B and results in column C. Result to be displayed on first occurence of item only.
Code:
Sub t()
Dim fn As Range, c As Range
With ActiveSheet
    .Range("A1", .Cells(Rows.Count, 1).End(xlUp)).AdvancedFilter xlFilterCopy, , .Cells(Rows.Count, 1).End(xlUp)(3), True
        For Each c In .Cells(Rows.Count, 1).End(xlUp).CurrentRegion.Offset(1)
            If Application.SumIf(.Range("A2", .Cells(Rows.Count, 2).End(xlUp)), c.Value, _
            .Range("B2", .Cells(Rows.Count, 2).End(xlUp))) >= 2 Then
                Set fn = .Range("A2", .Cells(Rows.Count, 2).End(xlUp)).Find(c.Value, , xlValues)
                    If Not fn Is Nothing Then
                        fn.Offset(, 2).Value = 1
                    End If
            End If
        Next
        .Cells(Rows.Count, 1).End(xlUp).CurrentRegion.ClearContents
End With
End Sub
 
Upvote 0
Or this formula

C2 copied down
=IF(AND(MATCH(A2,A:A,0)=ROW(A2),SUMIF(A:A,A2,B:B)>1),1,"")

M.
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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