如何隐藏行中没有数据的行

时间:2019-05-08 08:41:27

标签: excel vba

Public Sub caInvCompressRows(p_strInv As String)

Dim intRow As Integer
Dim intRowMch As Integer
Dim intCol As Integer
Dim bUsed As Boolean
Dim strTemp As String
Dim strSheet As String
Dim intSaveRow As Integer
strSheet = "cordINV-" & p_strInv
Call utlUnProtectSheet(strSheet, "alcatraz")
Sheets(strSheet).Select
Cells.Select
Rows.EntireRow.Hidden = False
Range("A1").Select
intRowMch = caINV_ROW_FIRST
While Cells(intRowMch, 1).Value <> "" Or Cells(intRowMch, 11).Value <> ""
    For intRow = intRowMch + 1 To intRowMch + 6
        If Cells(intRow, 1).Value = "" Then
            If Cells(intRow, 11).Value = "" Then
                Rows(intRow).EntireRow.Hidden = True
            End If
        End If
    Next intRow
    intRowMch = intRowMch + 9
Wend

End Sub

excel sheet example

我想用一个按钮隐藏没有数据的行。每行包含三个不同的数据组,这些数据组更改了需要隐藏的行。所有数据都被拉到C,O和AC列中,其余的都从中填充。

2 个答案:

答案 0 :(得分:0)

此公式仅通过串联整行,修剪结果并检查是否为空字符串来检查第2行中是否有任何东西:

=TRIM(TEXTJOIN("";FALSE;2:2))=""

答案 1 :(得分:0)

Sub HideRows()
 If Range("d2").Value = "" Then
    If Range("r2").Value = "" Then
        If Range("af2").Value = "" Then

Rows(“ 2:2”)。EntireRow.Hidden = True     万一     万一     如果结束

结束子