24周年

财税实务 高薪就业 学历教育
APP下载
APP下载新用户扫码下载
立享专属优惠
安卓版本:8.6.83 苹果版本:8.6.83
开发者:北京东大正保科技有限公司
应用涉及权限:查看权限>
APP隐私政策:查看政策>

高亮颜色标记单元格、行、列、行列实例

来源: 编辑: 2009/06/03 15:15:43  字体:

  1.高亮颜色标记单元格

  VBA代码:

  Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  On Error Resume Next
  Cells.FormatConditions.Delete
  With Target.FormatConditions
  .Delete
  .Add xlExpression, , "TRUE"
  .Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
  End With
  End Sub

  2.高亮颜色标记行

  Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  On Error Resume Next
  Cells.FormatConditions.Delete
  With Target.EntireRow.FormatConditions
  .Delete
  .Add xlExpression, , "TRUE"
  .Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
  End With
  End Sub

  3.高亮颜色标记列

  Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  On Error Resume Next
  Cells.FormatConditions.Delete
  With Target.EntireColumn.FormatConditions
  .Delete
  .Add xlExpression, , "TRUE"
  .Item(1).Interior.ColorIndex = Int(50 * Rnd() + 2)
  End With
  End Sub

  4.高亮颜色编辑行列

  Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  On Error Resume Next
  Cells.FormatConditions.Delete
  iColor = Int(50 * Rnd() + 2)
  With Target.EntireRow.FormatConditions
  .Delete
  .Add xlExpression, , "TRUE"
  .Item(1).Interior.ColorIndex = iColor
  End With
  With Target.EntireColumn.FormatConditions
  .Delete
  .Add xlExpression, , "TRUE"
  .Item(1).Interior.ColorIndex = iColor
  End With
  End Sub

责任编辑:zoe

实务学习指南

回到顶部
折叠
网站地图

Copyright © 2000 - www.chinaacc.com All Rights Reserved. 北京东大正保科技有限公司 版权所有

京ICP证030467号 京ICP证030467号-1 出版物经营许可证 京公网安备 11010802023314号

正保会计网校