Change cell type

D

Derick

Hi

I am using C# to try and format a range in Excel as numbers. When
doing this, I get the green error arrow in the corner to ask me if I
want to format the column as a number.

I used the code below to format the data:

Excel.Range Data = currentSheet.get_Range("K2:K10", Type.Missing);
Data.NumberFormat = "0.00";

How do I convert the range to numbers so that excel is happy?

Thanks
Derick
 
V

Vacuum Sealed

Derick

Try

Range("K2:K10").Select
Selction.NumberFormat= "0.00"

HTH
Mick.
 
J

Jim Rech

Excel isn't really unhappy. It's just that the optional error checking
feature is pointing out some possible inconsistency. The green markers do
no harm but if you want to turn them off it can be done on the Formulas tab
of Excel Options (Excel 2007 and 2010).
 
G

GS

Vacuum Sealed has brought this to us :
Derick

Try

Range("K2:K10").Select
Selction.NumberFormat= "0.00"

HTH
Mick.

Mick,
Since NumberFormat is a read/write property of the Range object, there
is no need to select it. (Unecessary selecting slows down code
performance)

Range("K2:K10").NumberFormat = "0.00"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top