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 |
Write formated excel values into text file
Hi
Use .Text rather than .Value Alok "kaiserlich" wrote: 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 |
All times are GMT +1. The time now is 04:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com