excel - Delete formulas in empty cells - Stack Overflow

I'm trying to delete formula formulas in empty cells cause my spreadsheet is too heavy and just sa

I'm trying to delete formula formulas in empty cells cause my spreadsheet is too heavy and just save it take like 30m. The last personn using this file put formulas in every cells.

Sub clearFormulaEmptyCells()
 Dim sh As Worksheet, rngForm As Range, rngDel As Range, cF As Range
 
 Set sh = ActiveSheet
 On Error Resume Next
  Set rngForm = sh.UsedRange.SpecialCells(xlCellTypeFormulas)
 On Error GoTo 0
 If rngForm Is Nothing Then Exit Sub
 For Each cF In rngForm.Cells      'iterate between cells having formula
    If cF.Value = "" Then          'find the ones returning the null strinig
        If rngDel Is Nothing Then  'if rngDel not Set:
            Set rngDel = cF        'Set it as first such a cell
        Else
            Set rngDel = Union(rngDel, cF) 'make a Union between the existing range and the cell returning a null string
        End If
    End If
 Next
 If Not rngDel Is Nothing Then rngDel.ClearContents  'it will clear the formula
End Sub

I try this but when i run it i have a mismatch type error 13 and excel underlign this row : If cF.Value = "" Then

Below the kind of formulas that i have in cells :

=IFERROR(IF(AND(H398<>"";M398<>"");H398-M398;"");"")
=IF(G400<>"";G400;"")

Every formulas have a IF or IFERROR.

Thanks for your help!

I'm trying to delete formula formulas in empty cells cause my spreadsheet is too heavy and just save it take like 30m. The last personn using this file put formulas in every cells.

Sub clearFormulaEmptyCells()
 Dim sh As Worksheet, rngForm As Range, rngDel As Range, cF As Range
 
 Set sh = ActiveSheet
 On Error Resume Next
  Set rngForm = sh.UsedRange.SpecialCells(xlCellTypeFormulas)
 On Error GoTo 0
 If rngForm Is Nothing Then Exit Sub
 For Each cF In rngForm.Cells      'iterate between cells having formula
    If cF.Value = "" Then          'find the ones returning the null strinig
        If rngDel Is Nothing Then  'if rngDel not Set:
            Set rngDel = cF        'Set it as first such a cell
        Else
            Set rngDel = Union(rngDel, cF) 'make a Union between the existing range and the cell returning a null string
        End If
    End If
 Next
 If Not rngDel Is Nothing Then rngDel.ClearContents  'it will clear the formula
End Sub

I try this but when i run it i have a mismatch type error 13 and excel underlign this row : If cF.Value = "" Then

Below the kind of formulas that i have in cells :

=IFERROR(IF(AND(H398<>"";M398<>"");H398-M398;"");"")
=IF(G400<>"";G400;"")

Every formulas have a IF or IFERROR.

Thanks for your help!

Share Improve this question edited Mar 17 at 8:40 FunThomas 30.1k4 gold badges23 silver badges38 bronze badges asked Mar 17 at 8:36 user29982961user29982961 51 bronze badge 2
  • Do you mean there's a difference between =IF(G400<>"";G400;"") and =G400?

    发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744572565a4581542.html

相关推荐

  • excel - Delete formulas in empty cells - Stack Overflow

    I'm trying to delete formula formulas in empty cells cause my spreadsheet is too heavy and just sa

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信