【问题标题】:Based on a Filtered count value from one sheet, need to insert empty rows in another sheet基于一张纸的过滤计数值,需要在另一张纸中插入空行
【发布时间】:2021-12-16 21:27:47
【问题描述】:

我在工作表 1 中有某些单元格值范围 (A1:A10)

基于一个标准,只有 A2、A3、A4 是适用的。

所以计数值为3

第 1 步:我需要过滤条件并将计数值设为 3。 第2步:根据计数值需要在另一张表中插入行(如当前值为3,因此需要插入3个空行)

【问题讨论】:

    标签: excel vba


    【解决方案1】:
    Sub Test()
    Dim arr, arr2, count%, criteria$
    criteria = "place your criteria"
    With Sheet(1)
        arr = Application.Transpose(.Range("A1:A10"))
        arr2 = arr
        count = 0
        For i = LBound(arr) To UBound(arr)
            If arr(i) = criteria Then
                arr2(i) = arr(i)
                count = count + 1
            End If
        Next i
    End With
    
    If x > 0 Then
        ReDim Preserve arr(1 To x)
        With Sheet(2)
            .Rows(1).EntireRow.Resize(count).Insert 'rows 1 or the row you want
        End With
    End If
    'Note you'vegot the filtered data in arr2
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 1970-01-01
      • 2019-12-08
      • 2013-02-11
      • 2018-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多