2012-05-29 543 views
2

此代码已运行多年。我想也许我无意中按了一个键,但我似乎无法看到它。我突然得到了错误:“无法设置Range类的NumberFormat属性”

无法设置Range类

的NumberFormat属性在下面的代码:

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 
+1

您是否在得到该错误时检查了“TempValue”的值?你得到你的错误的行看起来不错。 – assylias

+2

另外在错误发生时'''''',''''''x的值是多少? –

+0

y,k,x,j是完全精细的 - 6,0,2,1。 TempValue = -30081207.13 – mezamorphic

回答

5

在聊天发现的是工作簿中有不止的问题64,000格式,因此用户在Excel中获取“太多不同格式格式”错误消息

解决方案

主题:从上面的链接

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.

解决方案http://support.microsoft.com/kb/213904

QUOTE:你在Excel收到 “太多不同的单元格格式” 错误消息

链接正如链接中提到的那样,下载并运行XLStyesTool

+0

+1很好的支持! –