简体   繁体   English

Excel VBA 仅显示范围内具有空白单元格的行

[英]Excel VBA to Only show rows that have a blank cell in a range

I have a excel workbook i have built and I'm trying to improve it.我有一个 excel 工作簿,我正在努力改进它。 I have custom views that show specific data.我有显示特定数据的自定义视图。 I need the sheet to look at columns n- x and only show rows that have a blank cell(s).我需要工作表来查看 n-x 列,并且只显示具有空白单元格的行。

I have tried a begin row, end row with chkcol array but that isn't working.我尝试过使用 chkcol 数组的开始行和结束行,但这不起作用。

For my specific view of column nx if all the cells are filled out i don't need to see it anymore so i want it hidden in that view.对于我对 nx 列的特定视图,如果所有单元格都已填写,我不需要再看到它,所以我希望它隐藏在该视图中。

I don't know what rows you are doing, but this will do all of your usedrange.我不知道你在做什么行,但这将完成你所有的使用范围。 I didn't test it.我没有测试它。

Sub SubName()

Dim aCell As Range, WS As Worksheet
    Set WS = ActiveSheet

    For Each aCell In Intersect(WS.UsedRange, WS.Range("n:n")).Cells
        If Application.WorksheetFunction.CountBlank(Intersect(WS.Range("N:X"), aCell.EntireRow)) = 0 Then
            aCell.EntireRow.Hidden = True
        Else
            aCell.EntireRow.Hidden = False
        End If
    Next aCell

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM