基于VBA实现Excel十字交叉高亮显示

平时做表用的OFFICE的Excel

1 打开vbe编辑器

具体操作过程见我关于Excel利用VBA实现去掉单元格两边空格的方法。

2 双击左侧thisworkbook标签,并粘贴代码

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Cells.FormatConditions.Delete
    With Target.EntireColumn
        .FormatConditions.Add xlExpression, , "=true"
        .FormatConditions(1).Interior.Color = RGB(100, 255, 255)
    End With
    With Target.EntireRow
        .FormatConditions.Add xlExpression, , "=true"
        .FormatConditions(2).Interior.Color = RGB(100, 255, 255)
    End With
End Sub

3 查看效果

4.另存为xlsm格式,如果其他可能会把vba代码抹除

发布了72 篇原创文章 · 获赞 24 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/oYinHeZhiGuang/article/details/104592405
今日推荐