2015-07-06 43 views
0

我想隱藏表格中的重複單元格。見圖。隱藏表格中的重複單元格

http://imgur.com/UoNKcBI

結果(我manualy隱藏NotebookNames,那是什麼我的意見是關於)

http://imgur.com/jVnhJAa

在第一列中,我們得到了 「映像文件名」,我想隱藏(油漆細胞白色)的重複,只留下第一個「重複」了。 在第二列中有「圖像版本」,我也想在這裏隱藏重複項,但依賴於「圖像名稱」列。因此,如果有2次「Image S400」+ 1.3版,請隱藏第2張「圖像名稱」+「圖像版本」。

我正在嘗試這個,現在有條件格式,但我確定這不是方法。

這是可能與條件格式?還是我必須用VBA解決這個問題?

的問候和美好的一週

Declade

回答

0

你想隱藏單元格或行,如果你的選擇是您可以使用此子讀取所有的行到表中,如果二路映像名稱和圖像當前行的版本是以前的一些行成爲當前行會被隱藏的

Sub HideDoubleRst() 
Application.ScreenUpdating = False  
    Dim UR As Long, X As Long 
    Dim MyCol As Integer  
    MyCol = Range("A:A").Column 
    UR = Cells(Rows.Count, MyCol).End(xlUp).Row 
    For X = 2 To UR 
     If Cells(X, MyCol) = Cells(X - 1, MyCol) And Cells(X, MyCol + 1) = Cells(X - 1, MyCol + 1) Then 
     Rows(X).Select 
     Selection.EntireRow.Hidden = True 
     End If 
    Next X 

Application.ScreenUpdating =真 結束小組 或者,如果你只想隱藏2個細胞您CA n改變背景顏色和你fontcolor到白色

Sub ColorDoubleRst() 
Application.ScreenUpdating = False 

    Dim UR As Long, X As Long 
    Dim MyCol As Integer 

    MyCol = Range("A:A").Column 
    UR = Cells(Rows.Count, MyCol).End(xlUp).Row 
    For X = 2 To UR 
    If Cells(X, "A") = Cells(X - 1, "A") Then 
     Cells(X, "A").Select 
     With Selection.Font 
      .ThemeColor = xlThemeColorDark1 
     End With 
     With Selection.Interior 
      .ThemeColor = xlThemeColorDark1 
     End With 
     If Cells(X, "B") = Cells(X - 1, "B") Then 
      Cells(X, "B").Select 
      With Selection.Font 
       .ThemeColor = xlThemeColorDark1 
      End With 
      With Selection.Interior 
       .ThemeColor = xlThemeColorDark1 
      End With 

      If Cells(X, "F") = Cells(X - 1, "F") Then 
       Cells(X, "F").Select 
       With Selection.Font 
        .ThemeColor = xlThemeColorDark1 
       End With 
       With Selection.Interior 
        .ThemeColor = xlThemeColorDark1 
       End With 
      End If 
     End If 
    End If 
    Next X 
Application.ScreenUpdating = True 
End Sub 
+0

我想隱藏只是2個單元格。在A2中,我們有Image S400和B2 1.3。現在我只想在這種情況下隱藏單元格A3和B3,因爲它們與上面相同。例如「圖像名稱」是圖像S400,但「圖像版本」是1.4例如,然後只隱藏單元格「圖像名稱」 – Declade

+0

@Declare,我添加子ColorDoubleRst,我認爲你想 – Fabrizio

+0

這個作品真棒,謝謝您。但是我得到了最後一個問題,如果我想添加另一列來檢查那裏,我會在那裏做什麼?例如NotebookName列F? – Declade

相關問題