Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

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

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

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Solution

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

Link: 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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...