2017-06-19 14 views
0

我有六個日期列(格式相同)。這些列中有一些常見的日期。我嘗試在條件格式中使用「重複」選項,但是這給出了在六列中的任何一列中常見的所有值。我需要找到所有六列中常見的日期。我在excel工作表中有一組6列的日期。我如何在這6列中找到常見日期?

+0

您可以使用sumproduct和if來標識公共列。請爲您的問題提供示例。你應該能夠得到正確的答案 – Karpak

回答

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

所以2005年8月1日存在於所有六列中。

相關問題