`
阅: 106 | 回: 2
发表于2025/8/3 16:20:09 楼主 
头像 等级:初学者
积分:2
财富值:2.0
身份:普通用户
' 类模块: clsEventClassModule
Option Explicit

Private WithEvents App As Application

Private Sub Class_Initialize()
Set App = Application
End Sub

Private Sub App_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If TypeOf Sh Is Worksheet Then
Call HighlightActiveCellRowAndColumn(Sh, Target)
End If
End Sub


' 标准模块
Option Explicit

Public EventClassModule As New clsEventClassModule

Sub Auto_Open()
Set EventClassModule.App = Application
End Sub

Sub Auto_Close()
Set EventClassModule = Nothing
End Sub

Public Sub HighlightActiveCellRowAndColumn(ws As Worksheet, Target As Range)
On Error GoTo l_err

' 清除之前的高亮显示
ws.Cells.Interior.ColorIndex = xlNone

' 设置行范围并高亮显示
With ws.Rows(Target.Row)
.Interior.Color = RGB(255, 255, 0) ' 黄色
End With

' 设置列范围并高亮显示
With ws.Columns(Target.Column)
.Interior.Color = RGB(255, 255, 0) ' 黄色
End With

Exit Sub

l_err:
MsgBox "发生错误:" & Err.Description, vbCritical
End Sub


我的个性签名
发表于 2025/8/4 11:12:15   
头像 等级:大师
积分:219
财富值:3
身份:普通用户
宏代码的问题,可以联系我们工程师处理
我的个性签名
发表于 2025/8/4 16:25:48   
头像 等级:初学者
积分:2
财富值:2
身份:普通用户

回复:2楼


已解决,后续有问题再请教
我的个性签名

快速回复

目前不允许游客发表,请 登录 注册 后再发贴。