使用Vbscript自动用特定字符串填充可见单元格(过滤范围)

时间:2019-05-22 07:32:30

标签: excel vbscript

如果发现内容,则需要过滤C列以搜索“ sim”之类的文本内容,然后填充B列的单元格

   Dim lastRow ,xl
    With wb

         objSheet.Range("P1").Autofilter 16, Criteria1 ="=*sim*" 
         LastRow = objSheet.usedrange.rows.count
        If lastRow > 2 Then
           ' objSheet.Range(objSheet.Range("O2"), objSheet.Range("O" & lastRow)). _
               'SpecialCells(xlCellTypeVisible).Value = "SIMEX"
               objSheet.Range("O" & LastRow).Value = "SIMEX"


        End If

          WScript.Echo vbCrLf _
           & "LastRow:-" _
        '.Range("P:P").AutoFilter Field:=16 'clear the filter
    End With

实际结果如下:

Col1   Col2    Col3
asd    sim       sim
dfg    P2P       sim
fgh    sim       sim

0 个答案:

没有答案