Ignore 'Number Stored as Text' Error in Excel programmatically using VBA

后端 未结 4 2142
無奈伤痛
無奈伤痛 2021-01-06 09:18

I want to store text such as \'001234\' in a cell. I have set the number format of this cell to text. After storing, an error \'Number Stored as Text\' is shown in the form

相关标签:
4条回答
  • 2021-01-06 09:59

    You can select the range you want to work and then put for example (now added speechmarks):

    Range("A1:Z20").Application.ErrorCheckingOptions.NumberAsText = False
    
    0 讨论(0)
  • 2021-01-06 10:04

    The above examples turn off the "number stored as text" checking for the application.

    This code will turn it off for a particular cell:

    range("G93").Errors.Item(xlnumberastext).Ignore = True
    
    0 讨论(0)
  • 2021-01-06 10:05

    Consider:

    Sub Macro1()
        Application.ErrorCheckingOptions.NumberAsText = False
    End Sub
    

    This is a single line of a much larger macro to configure Excel when I begin working on a new computer.

    0 讨论(0)
  • 2021-01-06 10:08

    Alternately, instead of formatting the cell as text, you could format the cell as 000000 to get the leading 0's to show.

    0 讨论(0)
提交回复
热议问题