Question

I am working in a Excel VSTO project with C#. For certain columns, I have set the NumberFormat to Text using

someCell.EntireColumn.NumberFormat = "@";

But when numbers do happen to be in these columns, Excel shows a green arrow with warning "Number Stored as Text". I want to suppress this warning message.

I know how to do that in Excel: Options -> Formulas -> in Error checking rules, uncheck "Numbers formatted as text or preceded by an apostrophe". Is it possible to do this in C# code, and only to certain cells/ranges? Thanks!

enter image description here

Was it helpful?

Solution

There's (in VBA)

Dim c As Range

For Each c In Selection.Cells
    c.Errors(xlNumberAsText).Ignore = True
Next c

Seems like you can't address a whole range at once - have to loop through the cells

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top