周一至周五 : 08:30 - 17:30 客服专员电话/微信:17301649371 QQ:2627049059
微信咨询

扫码微信咨询

关注公众号

关注微信公众号

电话: 021 5161 9370
返回顶部
定位选定单元格式相同的全部单元格
显示全部楼层 倒序浏览 发表日期 2014-02-12 17:30:38 1737次阅读 0次回复
susan
2014-2-12 17:30:38
Sub 定位选定单元格式相同的全部单元格()
    Dim FirstCell As Range, FoundCell As Range
    Dim AllCells As Range
    With Application.FindFormat
        .Clear
        .NumberFormatLocal = Selection.NumberFormatLocal
        .HorizontalAlignment = Selection.HorizontalAlignment
        .VerticalAlignment = Selection.VerticalAlignment
        .WrapText = Selection.WrapText
        .Orientation = Selection.Orientation
        .AddIndent = Selection.AddIndent
        .IndentLevel = Selection.IndentLevel
        .ShrinkToFit = Selection.ShrinkToFit
        .MergeCells = Selection.MergeCells
        .Font.Name = Selection.Font.Name
        .Font.FontStyle = Selection.Font.FontStyle
        .Font.Size = Selection.Font.Size
        .Font.Strikethrough = Selection.Font.Strikethrough
        .Font.Subscript = Selection.Font.Subscript
        .Font.Underline = Selection.Font.Underline
        .Font.ColorIndex = Selection.Font.ColorIndex
        .Interior.ColorIndex = Selection.Interior.ColorIndex
        .Interior.Pattern = Selection.Interior.Pattern
        .Locked = Selection.Locked
        .FormulaHidden = Selection.FormulaHidden
    End With
    Set FirstCell = ActiveSheet.UsedRange.Find(What:="", SearchFormat:=True)
    If FirstCell Is Nothing Then
        Exit Sub
    End If
    Set AllCells = FirstCell
    Set FoundCell = FirstCell
    Do
        Set FoundCell = ActiveSheet.UsedRange.Find(after:=FoundCell, What:="", SearchFormat:=True)
        If FoundCell Is Nothing Then Exit Do
        Set AllCells = Union(FoundCell, AllCells)
        If FoundCell.Address = FirstCell.Address Then Exit Do
    Loop
    AllCells.Select
End Sub

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则  允许回帖邮件提醒楼主

快表软件是国内较早研究表格类软件开发平台的团队之一,迄今已有十多年的行业经验.致力于为企事业单位提供实用可靠的数字化平台。
  • 微信公众号

  • 微信小商店

  • 微信客服

  • Powered by Discuz! X3.4 | Copyright © 2022-2024, XiRong Soft. | 快表软件
  • 沪ICP备13033196号 | 营业执照 |上海西戎软件科技有限公司|沪公网安备31011502002146号|沪ICP备13033196号 |