2012-05-29 265 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很好的支持! –