I am using the below code to copy a range and create a text file.
This is working perfectly fine.
However, I need any blank column to be referenced as a tab in the saved text file.
I don't want tabs between each if no tab is needed.
Any help here?
Sub save_Off_Grid()
Dim filename As String, lineText As String
Dim myrng As Range, i, j
filename = ThisWorkbook.Path & "\BOOK1-" & Format(Now, "mmddyy- hhmmss") & ".txt"
Open filename For Output As #1
Set myrng = Range("AY3:CV999")
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & " ") & myrng.Cells(i, j)
Next j
Print #1, lineText
Next i
Close #1
End Sub
This is working perfectly fine.
However, I need any blank column to be referenced as a tab in the saved text file.
I don't want tabs between each if no tab is needed.
Any help here?
Sub save_Off_Grid()
Dim filename As String, lineText As String
Dim myrng As Range, i, j
filename = ThisWorkbook.Path & "\BOOK1-" & Format(Now, "mmddyy- hhmmss") & ".txt"
Open filename For Output As #1
Set myrng = Range("AY3:CV999")
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & " ") & myrng.Cells(i, j)
Next j
Print #1, lineText
Next i
Close #1
End Sub