[心得] Excel IFERROR修改所有錯誤公式 VBA實戰

看板Accounting (會計)作者 (小朋友)時間6年前 (2019/05/05 16:48), 編輯推噓3(300)
留言3則, 3人參與, 6年前最新討論串1/1
用途:將所有無效公式以IFERROR公式處理為空白字串 下載(xlam):https://reurl.cc/7neNy Demo:https://i.imgur.com/Oz6MOL5.gif
Demo下載(xlsm):https://reurl.cc/ApKaj xlam增益集使用方法:https://i.imgur.com/1KvzYVc.gif
== 記得以前在某所案件歸檔前的File Check 會檢查Excel檔案所有的無效公式(#DIV/0!, #NAME?, #N/A) 這些無效公式一兩個手動處理還好,但常常莫名就有上百個要處理, 這時慢慢一個一個處理就滿浪費時間的, 這個小VBA會檢查所有工作表的公式,如果是錯誤的公式的話,會用IFERROR把它包起來 原始碼如下,會開啟VBE(ALT+F11)的話可以直接複製貼上,再按F5執行即可: Sub Replace_Formula_by_Adding_IFERROR() Dim Sh As Worksheet Dim cell As Range Dim FormulaRng As Range On Error Resume Next For Each Sh In Worksheets Set FormulaRng = Sh.Cells.SpecialCells(xlCellTypeFormulas) If Not FormulaRng Is Nothing Then For Each cell In FormulaRng If IsError(cell) Then cell.Formula = "=iferror(" & Mid(cell.Formula, 2) & ", """")" End If Next cell End If Next Sh On Error GoTo 0 End Sub -- Accoding: https://www.facebook.com/AccodingTW/ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.70.245.105 ※ 文章網址: https://www.ptt.cc/bbs/Accounting/M.1557046132.A.BC5.html

05/05 21:53, 6年前 , 1F
謝謝分享,超實用的
05/05 21:53, 1F

05/06 19:43, 6年前 , 2F
剛歸完檔路過
05/06 19:43, 2F

05/07 08:18, 6年前 , 3F
05/07 08:18, 3F
文章代碼(AID): #1SpgDql5 (Accounting)
文章代碼(AID): #1SpgDql5 (Accounting)