跳到主要内容

在Excel工作表中滚动时如何突出显示整行/整行? 

如果您有一个包含多列的大型工作表,则很难区分该行上的数据。 在这种情况下,您可以突出显示活动单元格的整个行,以便在向下滚动水平滚动条时可以快速轻松地查看该行中的数据。本文将为您介绍一些解决此问题的技巧。

使用VBA代码滚动时突出显示整行

使用 Kutools for Excel 滚动时突出显示整行/列/行和列


以下VBA代码可以帮助您动态突出显示所选单元格的行,请执行以下操作:

1。 激活要突出显示所选单元格的整个行的工作表,然后右键单击工作表选项卡,然后选择 查看代码 从右键菜单中,查看屏幕截图:

doc突出显示整行1

2。 在开 Microsoft Visual Basic应用程序 窗口,请将以下代码复制到该空白模块:

VBA代码:滚动时突出显示整行

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice
Cells.Interior.ColorIndex = 0
Target.EntireRow.Interior.ColorIndex = 8
End Sub

3。 然后保存并关闭此代码,现在,当您单击一个单元格时,该选定单元格的整行将突出显示,如以下屏幕截图所示:

doc突出显示整行2
1
doc突出显示整行3

笔记:

1.您可以在此脚本中将突出显示颜色更改为您喜欢的另一种颜色,目标.EntireRow.Interior.ColorIndex = 8”,更改号码 8 到另一个颜色索引。

2.如果要禁用此代码,只需转到 Microsoft Visual Basic应用程序 窗口,然后删除代码。

3.此代码还可以突出显示所选单元格范围的行,如下所示:

doc突出显示整行4

4.此代码仅适用于当前工作表。

5.如果工作表中有一些彩色单元格,则应用此代码时,单元格颜色将丢失。


如果您想尝试一种新工具- Kutools for Excel,其 阅读视图,您可以轻松突出显示活动单元格的整行或整列或行和列。

Kutools for Excel : 带有300多个便捷的Excel加载项,可以在30天内免费试用. 

安装后 Kutools for Excel,请执行以下步骤:

1。 选择要突出显示行的单元格或单元格区域。

2。 点击 库工具 > 阅读视图 下拉按钮> 阅读版式设置,请参见屏幕截图:

3。 在 阅读版式设置 对话框中,选择一种需要突出显示 形状 部分,然后指定此形状的样式,同时,您可以根据需要选择其他选项,例如颜色或透明度,请参见屏幕截图:

Tips:如果要突出显示所选单元格的行和列,请选择 交错 在下面 形状 部分,然后选择 垂线 突出显示活动单元格的整个列。

4. 完成对话框中的设置后,请单击 Ok,现在,当您单击一个单元格时,整行将立即突出显示。 并且它将随着所选单元格的变化而动态移动。

笔记:

1.您可以通过取消选中 阅读视图 一次。

2。 此 阅读视图 功能将应用于您的工作簿中的所有工作表。

3。 此 阅读视图 下次启动工作簿时,该功能将被禁用。

4.使用此实用程序,将保留您的彩色单元格。

单击以了解有关此阅读版式的更多详细信息。

立即下载和免费试用Excel的Kutools!


Kutools for Excel:具有300多个方便的Excel加载项,可以在30天内免费试用,没有任何限制。 立即下载并免费试用!

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
grazie
Molto utile ,
Ho un problema però, annulla l'eventuale colore delle celle che seleziono o se volessi impostare altro colore a una cella quando la seleziono mi scompare.
grazie
This comment was minimized by the moderator on the site
Hello, andrea

It may be difficult to modify the VBA code, so, here, I recommend you to apply the Conditional Formatting feature for solving this problem, please view the below article:
https://www.extendoffice.com/documents/excel/3500-excel-highlight-selected-row-conditional-formatting.html

Or you can use the Kutools for Excel' Reading Layout feature, you can try it 30 days for free.
Please download from: https://www.extendoffice.com/download/kutools-for-excel.html
This comment was minimized by the moderator on the site
This is so cool, but it removes any existing highlights from cells unless they are the result of conditional formatting. Any way to avoid that?
This comment was minimized by the moderator on the site
Hello, BHarris
It may be difficult to modify the VBA code, so, here, I recommend you to apply the Conditional Formatting feature for solving this problem, please view the below article:
https://www.extendoffice.com/documents/excel/3500-excel-highlight-selected-row-conditional-formatting.html

Or you can use the Kutools for Excel' Reading Layout feature, you can try it 30 days for free.
Please download from: https://www.extendoffice.com/download/kutools-for-excel.html
This comment was minimized by the moderator on the site
Does not work for MS Office - Excel 2016
This comment was minimized by the moderator on the site
is there a way to get it to only do a set of 4 cells along the specific row?
This comment was minimized by the moderator on the site
Hello, David,
The following VBA code can help you to highlight the cells that you selected, please try it. Hope it can help you!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Target.Interior.ColorIndex = 8
End Sub
This comment was minimized by the moderator on the site
Hi thanks for providing the code....it is so useful for our report, but actually for my report the hyperlink is there in the other sheet in the same workbook and highlighted cell is there in the next sheet, that selected cell row total should be selected. but while running this code im getting a run-time error '1004'. will you please help me on this ...
This comment was minimized by the moderator on the site
Thank You for this !
This comment was minimized by the moderator on the site
Thank you for the code to highlight the whole row. It is *AWESOME* and is going to make scrolling spreadsheets so much easier.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations