Write formated excel values into text file

K

kaiserlich

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top