需要返回True值是共享相同值的相同值的总和是奇数

时间:2016-03-15 04:37:07

标签: excel

我需要确定来自给定公司ID的每个客户是否是一个奇怪的人。我倾向于查明总计“公司ID”的总和是否为奇数,如果它们共享相同的日期,则为TRUE-

因此,我们为此数据集一次添加一行:

Range(Range("m8"), Range("m8").End(xlToRight).End(xlDown)).ClearContents
sCol = Range("n3").Value
Set rgFind = Range("a2:j2").Find(sCol, lookat:=xlWhole, MatchCase:=True)
iCol = rgFind.Column
lRow = Range("a2").CurrentRegion.Rows.Count
vCrit = CDate(Range("N5"))
vCrit1 = CDate(Range("N6"))
Set rgData = Range(Cells(3, iCol), Cells(lRow, iCol))
Set rSearch = Sheet1.Range("E10", Sheet1.Range("E" & Rows.Count).End(xlUp))
For Each rgCell In rgData
    'Set rgFind = rgCell.Find(vCrit, lookat:=xlPart, MatchCase:=False)
    'If Not rgFind Is Nothing Then
    If rSearch >= vCrit Or rSearch <= vCrit1 Then
        Range(Cells(rgCell.Row, 1), Cells(rgCell.Row, 10)).Copy
        Cells(Rows.Count, 13).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
        Application.CutCopyMode = False
    End If
Next rgCell
Range("n5").Select

结果将是:

InvoiceableDate CompanyID  Single client from this company?
4/30/2012 4:00  30003134   
4/30/2012 4:00  30003134   
4/30/2012 4:00  1000009602 
4/30/2012 4:00  1075000    
4/30/2012 4:00  30003134  
4/30/2012 4:00  30003134   

接下来是:

InvoiceableDate CompanyID Single client from this company?
4/30/2012 4:00  30003134  True

接下来是:

InvoiceableDate CompanyID  Single client from this company?
4/30/2012 4:00  30003134   False
4/30/2012 4:00  30003134   False

其次是:

InvoiceableDate CompanyID  Single client from this company?
4/30/2012 4:00  30003134   False 
4/30/2012 4:00  30003134   False 
4/30/2012 4:00  1000009602 True

跟着:

InvoiceableDate CompanyID  Single client from this company?
4/30/2012 4:00  30003134   False
4/30/2012 4:00  30003134   False 
4/30/2012 4:00  1000009602 True 
4/30/2012 4:00  1075000    True 

最后:

InvoiceableDate CompanyID  Single client from this company?
4/30/2012 4:00  30003134   False
4/30/2012 4:00  30003134   False 
4/30/2012 4:00  1000009602 True 
4/30/2012 4:00  1075000    True
4/30/2012 4:00  30003134   True

对于长篇文章感到抱歉,我正在建立自己的词汇来正确解释问题。

1 个答案:

答案 0 :(得分:0)

根据你的问题,我可以说你的数据在col A和B中。

C栏,你的原告,应该是:

=IF(MOD(COUNTIFS($A$2:$A$1000;A2;$B$2:$B$1000;B2);2)<>0;TRUE;FALSE)

因此,如果Timestamp与CompanyID匹配,则计数会增加。 然后,如果总计数器是奇数,则返回TRUE。