跳到主要內容

如何快速刪除Excel中的所有命名範圍?

假設您在工作簿中創建了很多命名範圍,但是現在,您不再需要這些命名範圍了,如何在Excel中一次刪除所有命名範圍?


通過轉到名稱管理器刪除所有命名範圍

在“名稱管理器”對話框中,可以根據需要創建,編輯和刪除命名範圍。 請這樣做:

1。 去的 名稱管理員 通過點擊 公式 > 名稱管理員,請參見屏幕截圖:
doc刪除命名範圍1

2。 在 名稱管理員 對話框,按 轉移 鍵以選擇所有命名範圍或按住 按Ctrl 選擇不需要的鍵,請參見屏幕截圖:
doc刪除命名範圍1

3。 然後點擊 刪除 對話框頂部的按鈕,然後會出現一個提示框,提醒您是否確定要刪除名稱。
doc刪除命名範圍1

4。 然後點擊 OK,所有命名範圍都被一次刪除。

doc刪除命名範圍4 -2 doc刪除命名範圍5

查找所有命名範圍並將其替換為公式中的相應單元格引用

Kutools for Excel的 替換範圍名稱 實用程序能夠輕鬆找到所有在選定範圍,指定工作表或所有工作表中應用命名範圍的公式。 該實用程序的主要作用是用這些公式中的相應單元格引用替換所有命名的範圍。


廣告替換命名範圍1

Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!

使用VBA代碼刪除所有命名範圍

以下簡短的VBA代碼也可以幫助您刪除工作簿中的所有命名範圍。

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:刪除Excel中的所有命名範圍

Sub DeleteNames()
'Update 20140314
Dim xName As Name
For Each xName In Application.ActiveWorkbook.Names
    xName.Delete
Next
End Sub

3。 然後按 F5 鍵以運行此代碼,工作簿中的所有名稱將立即刪除。


相關文章:

最佳辦公生產力工具

🤖 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 (8)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
first if the excel extension is xls then convert it using excel to xlsx .then close excel. make a backup of your xlsx file. rename this backup extension to zip. under zip file there is a xl folder.under the xl folder there is a workbook.xml file. open it with xml notepad and delete defined names. or open it with notepad delete between <definednames> to </definednames>. and also delete this definednames parts too.then save this workbook.xml and drag drop inside zip files xl folder . then save it. and change the extension to xlsx file. open the file and press Ctrl+S. All defined names cleared with hidden ones.
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
You should check if it is an internal protected name range like so
```
Sub DeleteNames()
Dim xName As Name
For Each xName In Application.ActiveWorkbook.Names
If Split(xName.Name, ".")(0) <> "_xlfn" Then
xName.Delete
End If
Next
End Sub
```
This comment was minimized by the moderator on the site
This was an improved code from the prior. I had many names for which the delete button was dimmed out, wouldn't work, nor would the prior code. Yours removed all but one. Thank you!!
This comment was minimized by the moderator on the site

Sub DeleteNames()
    Dim xName As Name
    For Each xName In Application.ActiveWorkbook.Names
        If Split(xName.Name, ".")(0) <> "_xlfn" Then
            xName.Delete
        End If
    Next
End Sub
This comment was minimized by the moderator on the site
Run Time Error 7
out of memory
This comment was minimized by the moderator on the site
Hello, Murali
I have tested the code, it works well in my workbook.
Could you upload your workbook here, so that we can check where the problem is?

Thank you!
This comment was minimized by the moderator on the site
How about something a little more specific.

First Identify all unused named ranges, for review.

Second, macro to delete all unused named ranges.
This comment was minimized by the moderator on the site
When I try to run the above VBA Code, I get the following error:

Run-time error '1004'
The syntax of this name isn't correct.

Verify that the name:
- Starts with a letter or underscore
- Doesn't include a space or character that isn't allowed
- Doesn't conflict with an existing name in the workbook
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations