• vba:根据给定单元格搜索目标值


    Sub 德赛()

    Dim x
    Dim rng As Range

    Set rng = Range("$F$1:$F$1048576") '筛选目标列

    If ActiveSheet.AutoFilterMode = True Then '关闭筛选模式

    ActiveSheet.AutoFilterMode = False

    End If

    rng.AutoFilter Field:=1, Criteria1:="=*" & x & "*", Operator:=xlAnd '根据给定搜索条件筛选

    For i = 1 To Range("A1").CurrentRegion.Rows.Count '将筛选结果中字符串的第8个字符开始连续6个放在第7列

    c = Worksheets(1).Cells(i, 4).Value

    Worksheets(1).Cells(i, 7).Value = Mid(c, 8, 6)

    Next

    With Range("G1:G1048576") '筛选结果居中显示
    .HorizontalAlignment = xlCenter '水平居中baidu
    .VerticalAlignment = xlCenter '垂直zhi居中
    End With
    '
    'With rng

    '.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy Shift:=xlShiftUp

    'x = "1013B"
    'ActiveSheet.Range("$F$1:$F$1048576").AutoFilter Field:=1, Criteria1:="=*" & x & "*", Operator:=xlAnd
    'Set rng = Range("$F$1:$F$1048576")
    'rng.Offset(1).SpecialCells(xlCellTypeVisible).Delete Shift:=xlShiftUp
    End Sub

  • 相关阅读:
    .NET CF 枚举设备窗口
    .NET CF WM设备(手机)振动
    如何将 byte[] 转换为 IntPtr?
    Mobile 重启设备
    如何删除只读文件?
    随笔
    故乡的原风景
    岁月神偷
    opengl纹理映射
    bootstrap 学习笔记
  • 原文地址:https://www.cnblogs.com/yukit/p/14084048.html
Copyright © 2020-2023  润新知