跳到主要內容

如何在Excel中保留或刪除前導零?

通常,當我們在單元格中鍵入包含前導零的數字(如00032423)時,它可能顯示為32423。如何在Excel中保留這些前導零? 反之,當不需要顯示前導零時,該如何刪除呢?

使用格式單元格保持前導零

使用VBA刪除前導零

點擊即可使用Kutools for Excel刪除前導零 好主意3

使用Kutools for Excel添加/刪除相同的前導零


箭頭藍色右氣泡 使用格式單元格保持前導零

如果要在Excel中保留前導零,則只需在鍵入數據之前將單元格格式設置為“文本格式”。

1.選擇要輸入帶前導零的數據的範圍單元格,然後單擊右鍵選擇 單元格格式 從上下文菜單中。 看截圖:

doc-keep-delete-leader-zeor-1

2。 在裡面 單元格格式 對話框中單擊 聯繫電話 選項卡,然後選擇 文本 來自 類別 窗格。 請點擊 OK 關閉對話框。 看截圖:

doc-keep-delete-leader-zeor-2

現在,當您在範圍單元格中鍵入帶有前導零的數字時,前導零將保留在單元格中。 看截圖:

doc-keep-delete-leader-zeor-3

備註:如果您在鍵入數字後將單元格設置為文本格式,則此方法無效。


一鍵式刪除Excel中單元格中的所有前導零

只需單擊一下,選中的所有前導零都已刪除。  點擊免費試用30天!
文檔刪除前導零
 
Kutools for Excel:擁有300多個便捷的Excel加載項,可以在30天內免費試用。

箭頭藍色右氣泡 使用VBA刪除前導零

如果要刪除Excel中的前導零,則有四種解決方法。

方法1:將單元格格式化為數字格式

選擇要鍵入數字而不顯示前導零的範圍,然後右鍵單擊以單擊 單元格格式 打開 單元格格式 對話框,然後選擇 聯繫電話 來自 類別 窗格,然後單擊 OK. 

備註:如果您在鍵入數字後格式化單元格,則此方法將不起作用。

方法2:使用公式

選擇您已鍵入帶前導零的數字的範圍單元格旁邊的空白單元格,然後鍵入此公式 = VALUE(A1) (A1表示單元格包含前導零的數字)。 然後按 Enter 按鈕,現在公式單元格中顯示不帶前導零的數字。 看截圖:

doc-keep-delete-leader-zeor-4

方法3:運行VBA

1。 按 Alt + F11鍵 顯示 Microsoft Visual Basic for Applications 窗口。

2.在窗口中,單擊 插入 > 模塊 以顯示新的模塊窗口,然後將以下VBA代碼複製到模塊窗口中。

VBA:在Excel中刪除前導零

Sub DeleteZero()
'updateby20140616
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
WorkRng.NumberFormat = "General"
WorkRng.Value = WorkRng.Value
End Sub
3。 點擊 按鈕,然後會彈出一個KutoolsforExcel對話框,供您選擇要刪除前導零的範圍。 看截圖:

doc-keep-delete-leader-zeor-5

4。 點擊 OK。 然後刪除選擇中的前導零。

方法4:使用轉換為數字功能

選擇由以零開頭的數字填充的範圍單元格,單擊所選內容旁邊的警告圖標,然後選擇 轉換成數字 從上下文菜單中。 查看屏幕截圖:

doc-keep-delete-leader-zeor-6


箭頭藍色右氣泡 點擊即可使用Kutools for Excel刪除前導零

Excel的Kutools, 與以上 200 方便的功能,使您的工作更加輕鬆。 

安裝後 Kutools for Excel,請執行以下操作:(立即免費下載Kutools for Excel!)

如果你有 Excel的Kutools,您可以通過單擊兩次快速刪除文本中的所有前導零 刪除前導零 效用

選擇要刪除前導零的文本,然後單擊“確定”。 庫工具 > 文本 > 刪除前導零。 看截圖:
doc刪除前導零01

然後會彈出一個對話框,提醒您從多少個單元格中刪除了前導零。 看截圖:
doc刪除前導零02

點擊 OK 關閉對話框。

箭頭藍色右氣泡 刪除前導零




箭頭藍色右氣泡 使用Kutools for Excel添加/刪除前導零

如果要向單元格添加或刪除相同數量的前導零,則可以應用 Excel的Kutools's 添加文本按位置刪除 實用程序,一種可以幫助您向單元格中添加相同數量的前導零,一種可以幫助您從單元格左側刪除相同數量的字符串。

安裝後 Kutools for Excel,請執行以下操作:(立即免費下載Kutools for Excel!)

添加相同數量的前導零

1.首先,您需要將單元格格式設置為 文本 通過選擇它們並單擊 首頁 並去 數字 分組選擇 文本 從下拉列表中。 看截圖:
文檔庫工具 1

2.然後保持選中這些單元格,然後單擊 庫工具 > 文本 > 添加文本。 看截圖:
文檔庫工具 2

3。 在裡面 添加文本 對話框中,在您的文本框中輸入要添加的零 文本,並檢查 在第一個字符之前 選項,然後您可以在右側窗格中預覽添加結果。 看截圖:
文檔庫工具 3

4。 點擊 Ok or 登記,現在將相同數量的前導零添加到單元格中。
文檔庫工具 4

刪除相同數量的前導零

1.選擇要刪除前導零的單元格,然後單擊 庫工具 > 文本 > 按位置刪除。 看截圖:
文檔庫工具 5

2.在彈出的對話框中,輸入要刪除的零的數量,選中該選項,然後可以在“預覽”窗格中預覽結果。
文檔庫工具 6

3。 點擊 Ok or 登記,現在前導零立即被刪除。


分頁瀏覽和編輯多個Excel工作簿/ Word文檔,例如Firefox,Chrome,Internet Explore 10!

您可能很熟悉在Firefox / Chrome / IE中查看多個網頁,並通過輕鬆單擊相應的選項卡在它們之間進行切換。 在此,Office選項卡支持類似的處理,使您可以在一個Excel窗口或Word窗口中瀏覽多個Excel工作簿或Word文檔,並通過單擊它們的選項卡輕鬆地在它們之間進行切換。 免費點擊 30-Office Tab 試用版!

優秀

相關文章:

最佳辦公生產力工具

🤖 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 (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I want to keep the leading zero's when I copy from the program I use at work & paste onto excel with out having to manually re-enter them. I would also like to keep them when I use my scanner into excel. Using the 'Text' format I can manually re-enter them into the cell & they will stay. Is there a format so that they go in with the leading zero's already there?
This comment was minimized by the moderator on the site
Hi, McJoe, I do not understand your question clearly, if you want to copy text string with leading zeros from a program, maybe Word document, and paste them to a worksheet and keep the leading zeros, you just format the cells as text before you pasting.
This comment was minimized by the moderator on the site
I want to remove the zero infront of the - 3TT-0233449.How do I go about it?
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
Thanks it worked
This comment was minimized by the moderator on the site
This is the BEST Excel site for years going! IDK how they do so much volume. WorkRng.Value = WorkRng.Value =VALUE(A1) brilliant code.
This comment was minimized by the moderator on the site
value(a1) worked great, thank you soo much !
This comment was minimized by the moderator on the site
BRILLIANT WORK!!! Excellent
This comment was minimized by the moderator on the site
I wanted to display "0001" instead of "1" in excel as Excel removes leading zeroes. Solution: Use Format Cells/ Custom format/ Type = "0000" Done. Instead this page refers to "Kutools" THIRTEEN times. Who's writing this page? Obviously the author of Kutools or someone getting a kickback from it!
This comment was minimized by the moderator on the site
If you needed to use your newly formatted number to conduct an HVLookup it will not match other data that may have embedded leading zero's. The formatting method you are referring to displays the number the way you want to see it but it will not be useful in a data match or lookup while the VBA will work.
This comment was minimized by the moderator on the site
This comment is very helpful and is the correct approach for must users looking to perform this function retroactively on their data.


The Shill is also very real, lol.
This comment was minimized by the moderator on the site
You can also do

format cell > text format ( instead of Number or accounting or Currency or general )
This comment was minimized by the moderator on the site
But how to keep the leading zeroes when I download data directly from my website or from my warehouse program? The download is directly in excel, so I can not modify anything in advance. Is there any option in excel which determines in advance that the entire column or sheet must be read (downloaded) as text?
This comment was minimized by the moderator on the site
download file in.txt and open excel and desired column select and go to format cell and select as text, after this please open your .txt file and copy from .txt file and paste it in xl.... Done
This comment was minimized by the moderator on the site
Is there any way to do it from Excel tools ? In case we have n number of records this method is of no use.
This comment was minimized by the moderator on the site
using value(a1) worked great for deleting leading zeros
This comment was minimized by the moderator on the site
Nice try slick, your methods don't work. Didn't try VBA, surely there's an easier way than that.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations