Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default NumberFormat


Hi,
I am trying to do smth in excel and I can't.
I want to copy value of one cell in txt files. The content of cell is
43,5580 (type - Number, decimal places 4 .. ).
I created a button with short code behind:
Sub Button1_Click
Open "C:\Temp\Example.txt" For Output As #1

Set c = Worksheets("Sheet1").Range("A1")
c.NumberFormat = "$#,##0_);($#,##0)"

Print #1, c.Value
Close #1
End Sub

It doesn't work. As result I have 43.5580 ( '.' instead of ',' ).

When I input: MsgBox "The number format for cell A1 is " & _

Worksheets("Sheet1").Range("A1").NumberFormatLocal
the result is: 43,5580
but the value is 43.5580, and this is copied to Example.txt.

How to solve this problem

Thanks in advance


--
momak
------------------------------------------------------------------------
momak's Profile: http://www.excelforum.com/member.php...o&userid=25386
View this thread: http://www.excelforum.com/showthread...hreadid=388610

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default NumberFormat

Untested on my USA settings pc:

What happens if you use drop all the formatting stuff and just:

Print #1, c.Text

(since the cell is formatted the way you want.)

Try putting this in the immediate window:
?worksheets("sheet1").range("a1").text
(maybe quicker to test.)

momak wrote:

Hi,
I am trying to do smth in excel and I can't.
I want to copy value of one cell in txt files. The content of cell is
43,5580 (type - Number, decimal places 4 .. ).
I created a button with short code behind:
Sub Button1_Click
Open "C:\Temp\Example.txt" For Output As #1

Set c = Worksheets("Sheet1").Range("A1")
c.NumberFormat = "$#,##0_);($#,##0)"

Print #1, c.Value
Close #1
End Sub

It doesn't work. As result I have 43.5580 ( '.' instead of ',' ).

When I input: MsgBox "The number format for cell A1 is " & _

Worksheets("Sheet1").Range("A1").NumberFormatLocal
the result is: 43,5580
but the value is 43.5580, and this is copied to Example.txt.

How to solve this problem

Thanks in advance

--
momak
------------------------------------------------------------------------
momak's Profile: http://www.excelforum.com/member.php...o&userid=25386
View this thread: http://www.excelforum.com/showthread...hreadid=388610


--

Dave Peterson
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
.numberformat Q Aaron Excel Worksheet Functions 4 December 18th 09 02:15 AM
NumberFormat danpt Excel Discussion (Misc queries) 3 May 20th 09 10:55 PM
numberformat? Jack Sons Excel Discussion (Misc queries) 3 September 4th 07 03:44 PM
VBA NumberFormat Digit Excel Programming 1 January 30th 05 02:30 PM
Numberformat Syrus the Virus[_13_] Excel Programming 6 February 12th 04 02:12 PM


All times are GMT +1. The time now is 10:38 AM.

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

About Us

"It's about Microsoft Excel"