24周年

財稅實務(wù) 高薪就業(yè) 學歷教育
APP下載
APP下載新用戶掃碼下載
立享專屬優(yōu)惠

安卓版本:8.7.50 蘋果版本:8.7.50

開發(fā)者:北京正保會計科技有限公司

應(yīng)用涉及權(quán)限:查看權(quán)限>

APP隱私政策:查看政策>

HD版本上線:點擊下載>

高亮顏色標記單元格、行、列、行列實例

來源: 編輯: 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

實務(wù)學習指南

回到頂部
折疊
網(wǎng)站地圖

Copyright © 2000 - jnjuyue.cn All Rights Reserved. 北京正保會計科技有限公司 版權(quán)所有

京B2-20200959 京ICP備20012371號-7 出版物經(jīng)營許可證 京公網(wǎng)安備 11010802044457號