跳到主要內容

如何在Excel中快速從選定範圍內取消選擇單元格?

假設您需要從當前選擇中取消選擇某些單元格或範圍,則必須取消選擇整個選擇,然後再次重新選擇,因為一旦選擇了單元格,Excel便不會提供取消選擇的方法。 本文將列出一些棘手的指導,以從當前選擇中取消選擇部分單元格或範圍。

使用VBA代碼取消選擇部分單元格或範圍

從Kutools for Excel中取消選擇部分單元格或範圍

例如,您選擇了很多單元格,但現在發現有些不需要的單元格。 因此,您需要取消選擇它們,並保留其他選定的單元格,請參見以下屏幕截圖:


箭頭藍色右氣泡 使用VBA代碼取消選擇部分單元格或範圍

VBA是一種出色的方式來處理Excel中的某些操作,而使用Excel的命令則不容易。 取消選擇單元格或範圍也是如此。

步驟 1:選擇您要使用的範圍;

步驟 2:按住的同時單擊要取消選擇的單元格 按Ctrl 鍵。

步驟 3:按住 其他 + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

步驟 4:點擊 插入 > 模塊,然後將以下宏粘貼到“模塊窗口”中。

VBA用於從選擇中取消選擇活動單元

Sub UnSelectCell()
'Updateby20140314
Dim rng As Range
Dim InputRng As Range
Dim DeleteRng As Range
Dim OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set DeleteRng = Application.InputBox("Delete Range", xTitleId, Type:=8)
For Each rng In InputRng
    If Application.Intersect(rng, DeleteRng) Is Nothing Then
        If OutRng Is Nothing Then
            Set OutRng = rng
        Else
            Set OutRng = Application.Union(OutRng, rng)
        End If
    End If
Next
OutRng.Select
End Sub

步驟 5: 按 F5 運行此宏的鍵。 然後會彈出一個對話框,供您選擇工作範圍。 查看屏幕截圖:




步驟 6:然後點擊 OK,將彈出另一個對話框,供您取消選擇範圍內的單元格。 如果您要取消選擇該範圍內的多個單元格,可以按住 按Ctrl 按鈕以一一選擇它們。 看截圖:




步驟 7:點擊 OK,您可以看到結果:



箭頭藍色右氣泡 從Kutools for Excel中取消選擇部分單元格或範圍

如果需要從選擇中取消選擇許多單元格或範圍,則上述VBA並不是一個好方法。 因此,我們介紹了以下技巧 選擇範圍助手 的工具 Excel的Kutools。 它可以幫助您輕鬆快捷地取消選擇任何單元格或範圍。

Excel的Kutools 包括300多個便捷的Excel工具。 30天免費試用,不受限制。 立即獲取.

步驟 1:點擊 庫工具 > 選擇工具 >> 選擇範圍助手….

步驟 2:在 選擇範圍助手 對話框,檢查 取消選擇單元格 選項,然後單擊或拖動鼠標以從選擇中取消選擇單元格或範圍。 看截圖:

步驟 3:並且已從選擇中取消選擇了不需要的單元格。 最後,關閉 選擇範圍助手 對話框。

有關更多詳細信息 選擇範圍助手, 請拜訪 選擇範圍助手功能描述.


相關文章:

最佳辦公生產力工具

🤖 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 (4)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
thank you so much
Rated 5 out of 5
This comment was minimized by the moderator on the site
Why can't Excel just allow users to deselect cells by holding down Ctrl like Google Sheets does?? It's ridiculous
This comment was minimized by the moderator on the site
This code you posted above in VBA for deselecting active cell from selection crashes on me when I X out of the input dialog box and the deselected cells once again become selected cells. How do we fix the code so after you use the VBA code you can get out of it and not loose what you deselected?

Thanks
This comment was minimized by the moderator on the site
After I have deselected the range of cells I want to deselect I get an error when I try to close the pop-up input box for another range. how do I fix that in the code provided above? Thanks.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations