vba “无法设置 Range 类的 NumberFormat 属性”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10801537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:19:23  来源:igfitidea点击:

"Unable to set the NumberFormat property of the Range class"

excelvba

提问by mezamorphic

This code has been working for ages. I thought maybe I accidently pressed a key but I cannot seem to see it. I suddenly get the error:

这段代码已经工作了很长时间。我想也许我不小心按下了一个键,但我似乎看不到它。我突然收到错误:

Unable to set the NumberFormat property of the Range class

无法设置 Range 类的 NumberFormat 属性

in the below code:

在下面的代码中:

Worksheets("Sheet1").Cells(y + k, x + j).Select
TempValue = Worksheets("Sheet1").Cells(y + k, x + j).Value
Worksheets("Sheet1").Cells(y + k, x + j).NumberFormat = "#,##0" //ERROR HERE
Worksheets("Sheet1").Cells(y + k, x + j).Value = TempValue

回答by Siddharth Rout

The problem as discovered in Chat was the workbook had more than 64,000 formats because of which the user was getting the "Too many different cell formats" error message in Excel

在聊天中发现的问题是工作簿有超过 64,000 种格式,因此用户在 Excel 中收到“太多不同的单元格格式”错误消息

Solution

解决方案

Topic: You receive a "Too many different cell formats" error message in Excel

主题:您在 Excel 中收到“太多不同的单元格格式”错误消息

Link: http://support.microsoft.com/kb/213904

链接http: //support.microsoft.com/kb/213904

QUOTE from the above link

从上面的链接引用

In Microsoft Excel 2007/2010 files may produce the following error message;

Excel found unreadable content in the file

This problem occurs when the workbook contains more than approximately 4,000 different combinations of cell formats in Excel 2003 or 64,000 in Excel 2007 and higher.

在 Microsoft Excel 2007/2010 文件中可能会产生以下错误信息;

Excel 在文件中发现无法读取的内容

当工作簿在 Excel 2003 中包含超过大约 4,000 种不同的单元格格式组合或在 Excel 2007 及更高版本中包含 64,000 多种不同组合时,会出现此问题。

Solution as mentioned in the link is to download and run the XLStyesTool

链接中提到的解决方案是下载并运行XLStyesTool

回答by Tomas Paul

I met with this problem using Fuzzy LookUp AddIn in Office365ProPlus. After I run FuzzyLookUp only 10 rows of output were generated and this message popped up.

我在 Office365ProPlus 中使用 Fuzzy LookUp AddIn 遇到了这个问题。在我运行 FuzzyLookUp 后,只生成了 10 行输出并弹出了此消息。

Problem was caused by my local setting of Excell.

问题是由我本地的 Excell 设置引起的。

To fix it I had to change decimal separator from coma into dot under general Excel settings.

为了解决这个问题,我必须在一般 Excel 设置下将小数点分隔符从昏迷更改为点。

On my side it solved the problem perfectly.

在我这边它完美地解决了这个问题。