NumberFormat

  • Thread starter Thread starter momak
  • Start date Start date
M

momak

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
 
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.)
 
Back
Top