Save with filename ACJRNyyyymmddhhmm
Hi again, please find the modified macro...
Dim intFile As Integer, strFile As String
intFile = FreeFile
strFile = "ACJRN" & Format(Now, "YYYYMMDDhhmm") & ".txt"
Open strFile For Output As #intFile
For Each rngRow In ActiveSheet.UsedRange.Rows
strData = ""
For Each cell In rngRow.Cells
strData = strData & Trim(cell)
Next
Print #intFile, strData
Next
Close #intFile
If this post helps click Yes
---------------
Jacob Skaria
"PVANS" wrote:
Good morning
I am currently using the following code to save a worksheet as a custom .CSV
filetype:
intFile = FreeFile
Open "c:\test.txt" For Output As #intFile
For Each rngRow In ActiveSheet.UsedRange.Rows
strData = ""
For Each cell In rngRow.Cells
strData = strData & Trim(cell)
Next
Print #intFile, strData
Next
Close #intFile
As you can see, it saves the file as "test.txt". However, as I will need to
run this macro daily, I need to be able to save the file with the following
filename:
"ACJRNyyyymmddhhmm.txt" eg: today would be (assuming I ran the macro at the
time I wrote this query)
"ACJRN200909231006.txt"
Could someone please suggest a method that would achieve this desired
filename each day? Please note, it is critical that I keep the formatting,
within the file, that has been achieved by the above code.
|