1

我有一个基于单元格值隐藏行的宏。我试图在工作簿中的多个工作表中使用它,但不是全部。我下面的代码似乎在同一张表中多次运行宏。

Sub HideRowsWbk()
Dim LastRow As Long
Dim Rng As Range
Dim ws As Worksheet

Application.ScreenUpdating = False
With ThisWorkbook
    For Each ws In .Worksheets
        Select Case ws.Name
        Case "0000_Index", "000_BidItems", "000_EntrySheet", "000_PayReqs"
             'do nothing - exclude these sheets

        Case Else
            With ws
                LastRow = Range("A65536").End(xlUp).Row '
                Set Rng = Range("M15:M" & LastRow) 'choose column where value exists

                For Each cell In Rng
                    If cell.Value = "0" Or cell.Value = "-" Then  'checks if cell value is 0 or -
                        cell.EntireRow.Hidden = True
                    End If
                Next cell
            End With
        End Select
    Next ws
End With

Application.ScreenUpdating = True

结束子

请告诉我我做错了什么以及如何解决这个问题。另外请告诉我如何提高我的最低编码技能。我正在使用 Excel 2007。

谢谢你。

4

1 回答 1

1

利用:

LastRow = .Range("A65536").End(xlUp).Row '
Set Rng = .Range("M15:M" & LastRow) 'choose column where value exists

" . " 使它与ws一起工作

于 2013-09-13T15:50:11.817 回答