![]() |
Automation:insert number to Excel problem
Hi.
I use Range to insert some numbers to the sheet. All works find. But I have one problem. Excel converts numbers like 2.76 to 1 febrary 1976. How to avoid this? |
Automation:insert number to Excel problem
It sounds like the cells format is incorrect
Have you tried changing the cell format to number ? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200601/1 |
Automation:insert number to Excel problem
Artem,
If your locallized date setting allows the use of . as the date delimiter, then Excel could interpret "2.76" (a string) as a date. Beyond that, post your code. HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Hi. I use Range to insert some numbers to the sheet. All works find. But I have one problem. Excel converts numbers like 2.76 to 1 febrary 1976. How to avoid this? |
Automation:insert number to Excel problem
Thank you for interest.
I understand this,but how can i avoid tis behaviour? I can't post my code today,i make this tomorrow. But in general I Get Range from the Worksheet and add SafeArray there. Number represented by string. "Bernie Deitrick" wrote: Artem, If your locallized date setting allows the use of . as the date delimiter, then Excel could interpret "2.76" (a string) as a date. Beyond that, post your code. HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Hi. I use Range to insert some numbers to the sheet. All works find. But I have one problem. Excel converts numbers like 2.76 to 1 febrary 1976. How to avoid this? |
Automation:insert number to Excel problem
Artem,
Check your "Regional and language options" from the control panel in windows, specifically, the regional options for short date. How to avoid this in the code depends on how you are assigning your cell values. Perhaps along the lines of: With Range("A1") .NumberFormat = "0.00" .Value = CDbl(SafeArray(i)) End With HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Thank you for interest. I understand this,but how can i avoid tis behaviour? I can't post my code today,i make this tomorrow. But in general I Get Range from the Worksheet and add SafeArray there. Number represented by string. "Bernie Deitrick" wrote: Artem, If your locallized date setting allows the use of . as the date delimiter, then Excel could interpret "2.76" (a string) as a date. Beyond that, post your code. HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Hi. I use Range to insert some numbers to the sheet. All works find. But I have one problem. Excel converts numbers like 2.76 to 1 febrary 1976. How to avoid this? |
Automation:insert number to Excel problem
How can I do this,and for what have i to change it?
"Crowbar via OfficeKB.com" wrote: It sounds like the cells format is incorrect Have you tried changing the cell format to number ? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200601/1 |
Automation:insert number to Excel problem
Hi,
Here are my code: CString start; start.Format(_T("A%d"),m_rowsCount+2); CRange oRange; oRange = m_sheet.get_Range(COleVariant(start), m_covOptional); oRange = oRange.get_Resize(COleVariant((short)1),COleVarian t((short)m_numberOfFields)); oRange.put_NumberFormat(COleVariant(_T("#,##0.00") ) ); oRange.put_NumberFormatLocal(COleVariant(_T("#,##0 .00")) ); oRange.put_Value(sa); ,where sa is COleSafeArray. But when i try to change number format I get COleDispatchException - "Can't change number format of class Range". What I'm doing wrong. "Bernie Deitrick" wrote: Artem, Check your "Regional and language options" from the control panel in windows, specifically, the regional options for short date. How to avoid this in the code depends on how you are assigning your cell values. Perhaps along the lines of: With Range("A1") .NumberFormat = "0.00" .Value = CDbl(SafeArray(i)) End With HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Thank you for interest. I understand this,but how can i avoid tis behaviour? I can't post my code today,i make this tomorrow. But in general I Get Range from the Worksheet and add SafeArray there. Number represented by string. "Bernie Deitrick" wrote: Artem, If your locallized date setting allows the use of . as the date delimiter, then Excel could interpret "2.76" (a string) as a date. Beyond that, post your code. HTH, Bernie MS Excel MVP "Artem Omelianchuk" wrote in message ... Hi. I use Range to insert some numbers to the sheet. All works find. But I have one problem. Excel converts numbers like 2.76 to 1 febrary 1976. How to avoid this? |
Automation:insert number to Excel problem
I make some research and find, that this behavior because of
UseSystemSeparators property. So now I turn off this property and all works fine. Thanks. |
All times are GMT +1. The time now is 05:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com