跳到主要內容

在Excel工作表中滾動時如何突出顯示整行/整行? 

如果您有一個包含多列的大型工作表,則很難區分該行上的數據。 在這種情況下,您可以突出顯示活動單元格的整個行,以便在向下滾動水平滾動條時可以快速輕鬆地查看該行中的數據。本文將為您介紹一些解決此問題的技巧。

使用VBA代碼滾動時突出顯示整行

使用Kutools for Excel滾動時突出顯示整個行/列/行和列


以下VBA代碼可以幫助您動態突出顯示所選單元格的行,請執行以下操作:

1。 激活要突出顯示所選單元格的整個行的工作表,然後右鍵單擊工作表選項卡,然後選擇 查看代碼 從右鍵菜單中,查看屏幕截圖:

doc突出顯示整行1

2。 在開 Microsoft Visual Basic for Applications 窗口,請將以下代碼複製到該空白模塊:

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.您可以在此腳本中將突出顯示顏色更改為您喜歡的另一種顏色,target.entirerow.interior.ColorIndex = 8”,更改號碼 8 到另一個顏色索引。

2.如果要禁用此代碼,只需轉到 Microsoft Visual Basic for Applications 窗口,然後刪除代碼。

3.此代碼還可以突出顯示所選單元格範圍的行,如下所示:

doc突出顯示整行4

4.此代碼僅適用於當前工作表。

5.如果工作表中有一些彩色單元格,則應用此代碼時,單元格顏色將丟失。


如果您想嘗試一種新工具- Excel的Kutools,其 閱讀版式,您可以輕鬆突出顯示活動單元格的整行或整列或行和列。

Excel的Kutools : 帶有300多個便捷的Excel加載項,可以在30天內免費試用. 

安裝後 Excel的Kutools,請執行以下步驟:

1。 選擇要突出顯示行的單元格或單元格區域。

2。 點擊 庫工具 > 閱讀版式 下拉按鈕> 閱讀版式設置,請參見屏幕截圖:

3。 在 閱讀版式設置 對話框中,選擇一種需要突出顯示 形狀 部分,然後指定此形狀的樣式,同時,您可以根據需要選擇其他選項,例如顏色或透明度,請參見屏幕截圖:

保養竅門:如果要突出顯示所選單元格的行和列,請選擇 交錯形狀 部分,然後選擇 垂線 突出顯示活動單元格的整個列。

4. 完成對話框中的設置後,請單擊 Ok,現在,當您單擊一個單元格時,整行將立即突出顯示。 並且它將隨著所選單元格的變化而動態移動。

筆記:

1.您可以通過取消選中 閱讀版式 一次。

2。 此 閱讀版式 功能將應用於您的工作簿中的所有工作表。

3。 此 閱讀版式 下次啟動工作簿時,該功能將被禁用。

4.使用此實用程序,將保留您的彩色單元格。

單擊以了解有關此閱讀版式的更多詳細信息。

立即下載和免費試用Excel的Kutools!


Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為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