尝试隐藏未填充的行并在其中包含值,可以做相反的事情但很麻烦

时间:2019-05-08 14:23:59

标签: excel vba

我有一个vba宏,如果有“ 1”和突出显示的单元格,它将隐藏整行。

但是我正尝试相反。隐藏行中没有填充“ 1”的行,这样我只能看到行中填充有“ 1”的行。

Sub HideRows()

Dim startRow As Integer
Dim EndColumn As Integer
Dim StartColumn As Integer
Dim currentRow As Integer

startRow = 2
StartColumn = 2
EndColumn = 30
currentRow = startRow

Do While Sheet2.Cells(currentRow, 1) <> ""

For i = StartColumn To EndColumn

    If Sheet2.Cells(currentRow, i) <> Sheet1.Cells(currentRow, i) Then
         Sheet2.Cells(currentRow, i).EntireRow.Hidden = True
         Sheet1.Cells(currentRow, i).EntireRow.Hidden = True


    End If

Next i

currentRow = currentRow + 1
Loop

End Sub

我尝试将“ <>”替换为“ =”,但是没有产生任何效果。任何提示/建议将不胜感激。

0 个答案:

没有答案