How can I use VBA to ignore green triangle error in range without looping cell by cell?

前端 未结 5 687
后悔当初
后悔当初 2021-01-02 20:30

I have some large data sets that I am automating and distributing. I want to eliminate the little green triangles that warn the user about numbers stored as text. I have use

5条回答
  •  佛祖请我去吃肉
    2021-01-02 21:04

    I have created a nifty procedure to put the error in the 'ignore' list: Have fun

    Sub SetInconsistentFormulaErrorsFalse(rng As Range, _
    Optional arrErrortypes As Variant = Null, _
    Optional bIgnoreErrors As Boolean = True)
    
    Dim cl As Range
    Dim i As Integer
    
    If IsNull(arrErrortypes) Then
       arrErrortypes = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
    End If
    
    For i = 0 To UBound(arrErrortypes) - 1
        For Each cl In rng.Cells
            cl.Errors(arrErrortypes(i)).Ignore = bIgnoreErrors
        Next
    Next i
    
    
    Set cl = Nothing
    
    End Sub
    

提交回复
热议问题