我在Excel工作表的6列中有一组日期。如何在所有这6列中找到常见日期?

时间:2017-06-19 11:11:56

标签: excel ms-office excel-2016

我有六列日期(格式相同)。每个列中都有一些常见日期。我尝试在条件格式中使用'duplicate'选项,但这给出了六列中任何一列中常见的所有值。我需要找到所有六列中常见的日期。

1 个答案:

答案 0 :(得分:0)

使用以下数据:

enter image description here

这个简短的宏:

Sub Kommon()
    Dim i As Long, N As Long, j As Long, d As Date, IsGood As Boolean
    N = Cells(Rows.Count, "A").End(xlUp).Row
    With Application.WorksheetFunction
    For i = 1 To N
        d = Cells(i, 1).Value
        IsGood = True
            For j = 2 To 6
                If .CountIf(Range(Cells(1, j), Cells(Rows.Count, j)), d) = 0 Then
                    IsGood = False
                End If
            Next j
        If IsGood Then
            Cells(i, 1).Interior.ColorIndex = 27
        End If
    Next i
    End With
End Sub

循环下一列并检查其他五列:

enter image description here

所有六列中都有 8/1/2005