Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 c++ automation problem. Ken Excel Worksheet Functions 0 January 9th 07 12:13 AM
Excel Automation Problem With Add-Ins pagates Excel Programming 4 October 6th 05 05:18 PM
Problem in graph automation in excel. news.microsoft.com[_7_] Excel Programming 3 April 30th 05 06:02 AM
TypeConverter Excel-Automation problem Markus Excel Programming 0 August 23rd 04 11:17 AM
How to insert Excel Worksheet Name using Automation in VB Dot Net?? Vanessa[_2_] Excel Programming 2 August 26th 03 03:57 PM


All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"