EXCEL 点击单元格,所在行列如何高亮

EXCEL工具栏一定要有 开发工具,没有的看下图1,有的直接跳图2

上图为图1

上图为图2

上图为图3

具体代码在下面,自己复制上去,就有效了

复制代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
Dim j As Integer
Dim lastRow As Long, lastCol As Long

' 清除之前的颜色
Cells.Interior.ColorIndex = xlNone

' 获取最大范围
lastRow = Cells(Rows.Count, Target.Column).End(xlUp).Row
lastCol = Cells(Target.Row, Columns.Count).End(xlToLeft).Column

' 高亮当前行
Rows(Target.Row).Interior.Color = RGB(255, 255, 0)

' 高亮当前列
Columns(Target.Column).Interior.Color = RGB(255, 255, 0)

End Sub
相关推荐
Non-existent98715 天前
WPS批量清理单元格空白字符的4种方法-异常数字格式处理-实战
excel·wps
Channing Lewis15 天前
PHP 解析 Excel 的那些坑:一次“行号错位”引发的数据丢失
开发语言·php·excel
jarreyer15 天前
【数据分析绘图】excel绘图和bi工具区别
数据挖掘·数据分析·excel
chatexcel15 天前
ChatExcel Max使用教程:图片、PDF、网页与复杂Excel的一站式数据分析
数据分析·pdf·excel
cngkqy15 天前
excel从某一列中用match筛选匹配的数据
excel
qq_5469372715 天前
Excel批量转PDF_Word_图片,支持自动合并报表,效率翻倍。
pdf·word·excel
ai_coder_ai15 天前
在自动化脚本中操作excel文件
运维·自动化·excel
三千花灯15 天前
【Playwright】 自动化测试之参数化登录(Excel/CSV 数据源)
人工智能·机器学习·excel
罗政15 天前
AI工作流实现Excel全自动化(支持SQL)-案例:医院门诊排班表
人工智能·自动化·excel
小妖66615 天前
excel 怎么在单元格内容自动加上一段文字不能用公式
excel·vba