防止Excel将字符串格式化为日期

问题描述:

我想在这样的单元格中插入类型为10/3的字符串:

I want to insert a string of type 10/3 in a cell like this:

Worksheets("Sheet1").Range("A1").Value = "10/3"

但是Excel会自动将单元格设置为日期或数字格式.我想把它作为字符串.

But Excel automatically formats the cell as a date or a number. I want to have it as a string.

如何使用VBA做到这一点?

How can I achieve this with VBA?

Worksheets("Sheet1").Range("A1").NumberFormat = "@"
Worksheets("Sheet1").Range("A1").Value = "10/3"