显示“存储为文本的数字”错误

我正在使用高级filter,其中包括0和1。 只有在数据表中,带有1和0的单元格显示错误消息“存储为文本号”,filter才能正常工作。 为此,我必须双击手动打开单元并按Enter键。 然后出现错误消息,filter工作。 如果我不这样做,filter不起作用。

或者我可以用1或0单击单元格并按F2显示错误消息。

有没有办法与VBA,我可以自动做到这一点?

非常感谢您的帮助!

你会发现深埋在单元格的Range属性中,特别是在Errors集合中。 只要find出现错误的单元格,然后将Ignore属性设置为True

 Public Sub IgnoreNumsAsText() Dim current As Range For Each current In ActiveSheet.UsedRange.Cells With current If .Errors.Item(xlNumberAsText).Value = True Then .Errors.Item(xlNumberAsText).Ignore = True End If End With Next current End Sub