![]() |
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 |
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 |
All times are GMT +1. The time now is 03:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com