NormChart55
New Member
- Joined
- Feb 22, 2022
- Messages
- 44
- Office Version
- 2016
- Platform
- Windows
Hello,
I have this macro that saves data into a comma delimited .txt file that I can import into another system. The file has to be .txt as the system does not recognize .csv. I am trying to add to the file name a date and timestamp of when it was created and to save into a specific folder. Currently it saves into my documents folder but would like to keep them in another without having to move. Any thoughts on how to do that with this macro? Any help is certainly appreciated.
I have this macro that saves data into a comma delimited .txt file that I can import into another system. The file has to be .txt as the system does not recognize .csv. I am trying to add to the file name a date and timestamp of when it was created and to save into a specific folder. Currently it saves into my documents folder but would like to keep them in another without having to move. Any thoughts on how to do that with this macro? Any help is certainly appreciated.
VBA Code:
Const MyDelimiter As String = ","
Dim iData As Range
Dim iRng As Range
Dim iFile As Long
Dim iResult As String
iFile = FreeFile
Open "ManualFix.txt" For Output As #iFile
For Each iData In Range("AF7:AF" & Range("AF" & Rows.Count).End(xlUp).Row)
With iData
For Each iRng In Range(.Cells, Cells(.Row, Columns.Count).End(xlToLeft))
iResult = iResult & MyDelimiter & iRng.Text
Next iRng
Print #iFile, Mid(iResult, 2)
iResult = Empty
End With
Next iData
Close #iFile
End Sub