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

扫码微信咨询

关注公众号

关注微信公众号

电话: 021 5161 9370
返回顶部
求助 vba中如何将高亮显示限制在指定范围内
显示全部楼层 倒序浏览 发表日期 2024-12-27 09:20:09 561次阅读 1次回复
微信图片_20241227091759.png
  1. Dim currentRow As Long, currentCol As Long
  2.                     Dim colorIndex As Long
  3.                         If GL Then
  4.                             ' 获取当前选中单元格的行号和列号
  5.         '                        msgbox("1")
  6.                             currentRow = e.RangeSelection.Row
  7.                             currentCol = e.RangeSelection.Column
  8.         '                    msgbox(currentRow & "12" & currentCol)
  9.                             ' 定义要使用的颜色索引(可以根据需要修改)
  10.                             colorIndex = 16 ' 例如,使用黄色(索引6)
  11.                             
  12.                             ' 清除之前的高亮(如果有的话)
  13.                             With AW.ActiveWorksheet.UsedRange.Interior
  14.                                         .Pattern = SpreadsheetGear.Pattern .None
  15.                             End With
  16.         '                    msgbox("1234")
  17.                             ' 高亮显示当前行和列
  18.                                 If e.RangeSelection.Intersect(Range("T_113")) IsNot Nothing Then
  19.                                     With e.RangeSelection.EntireRow.Interior  
  20.         '                                With Range("T_113").Rows(currentRow).EntireRow.Interior
  21.                                         .colorIndex = colorIndex
  22.                                     End With
  23.                 '                        msgbox("12345")
  24.                                     With e.RangeSelection.EntireColumn.Interior
  25.         '               With Range("T_113").EntireColumn.Interior
  26.                                         .colorIndex = colorIndex
  27.                                     End With       
  28.                                 End If
  29.                         End If
复制代码
e.RangeSelection.EntireRow.Interior 只能设置到整行 或是整列
本帖最后由 快表帝国客服01 于 2025-1-10 08:28 编辑

将currentRow与 currentCol限制在T_113的区域行列之内,也即是行号大于区域的第一行 小于最后一行,列大于第一列小于最后一列,在整个范围内起作用
另:企业版默认支持该功能,不用自定义写VBA

精彩评论1

本帖最后由 快表帝国客服01 于 2025-1-10 08:28 编辑

将currentRow与 currentCol限制在T_113的区域行列之内,也即是行号大于区域的第一行 小于最后一行,列大于第一列小于最后一列,在整个范围内起作用
另:企业版默认支持该功能,不用自定义写VBA
您需要登录后才可以回帖 登录 | 立即注册

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

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

  • 微信小商店

  • 微信客服

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