View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kaiserlich kaiserlich is offline
external usenet poster
 
Posts: 5
Default Write formated excel values into text file

Hi there,

i try to write a selected range by a user into a .txt file.

Here is the code:

Sub WriteFile()

Dim OutputFile As String
OutputFile = "C:\test.txt"

Dim myRange As Range
Set myRange = Selection

Open OutputFile For Output As #1

For Each rngCell In myRange.Cells

inhalt = Cells(rngCell.Row, rngCell.Column).Value
'inhalt = Mid(inhalt, 2, 2)

Print #1, inhalt

Next rngCell

Close #1

End Sub


All text values are written well. But for example:

Excel value: 10:15:00 AM
Text File value: 0.427083333333333

How can i make that he writes the proper values?

Thank you for help!

greetz
kaiserlich