Loading... 来源于:「知乎-阿尔法」<div class="tip inlineBlock error"> 设置高亮跟随显示后,表中原有填充色则会被取消。 </div> 如下图,表中信息较多,所以在查看时容易“串行”。此时可以让选中单元格所在的行、列高亮显示。  ### Step1:为Excel加载VBA功能   ### **Step2:组合键“ALT + F11”打开VBA编辑窗口** **→** **粘贴如下代码** ``` Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim rng1 As Range, rng2 As Range, ranges As Range Cells.Interior.ColorIndex = xlNone '清空所有颜色 Set rng1 = ActiveCell.EntireRow Set rng2 = ActiveCell.EntireColumn Set rng3 = Application.Union(rng1, rng2) rng3.Interior.ColorIndex = 20 Range("A1:AK2").Interior.ColorIndex = 1 End Sub ```  ### 最后,显示效果如下图:  ### **【说明】:** ① 可以通过修改代码“rng3.Interior.ColorIndex = 20”中的阿拉伯数字(显示色标记)自定义高亮显示颜色; ② VBA中不同色块的标记如下:  Last modification:April 16, 2022 © Allow specification reprint Support Appreciate the author WeChat Like 0 如果觉得我的文章对你有用,请帮忙点一下上面的广告
One comment
鸟叔来串门,通过虫洞穿梭至此,期待回访!