I am using a VBA macro to save a range as text.
It was working, but when i expanded my range it started saving the end of the range at the front as well as at the end. I am hoping for some direction on this. If someone can help with the xldown on the range too that would be amazing.
example of results:
SHOULD BE: (JUST EXAMPLE)
1 2 3 4 5 6 7 8 9 10
What I am getting:
9 10 1 2 3 4 5 6 7 8 9 10
It was working, but when i expanded my range it started saving the end of the range at the front as well as at the end. I am hoping for some direction on this. If someone can help with the xldown on the range too that would be amazing.
VBA Code:
Sub save_CRM()
Dim filename As String, lineText As String
Dim myrng As Range, i, j
Set Cell = Worksheets("Form").Range("D15")
filename = ThisWorkbook.Path & "\CRM Upload-" & Format(Now, "mm_dd_yy- hh_mm_ss") & Cell.Value & ".txt"
Open filename For Output As #1
Set myrng = Sheets("Sheet1").Range("AY3:CX9999") ' need to fix for xldown
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & vbTab) & myrng.Cells(i, j)
Next j
Print #1, lineText
Next i
Close #1
Sheets("Form").Activate
Application.ScreenUpdating = True
MsgBox "Completed - Please check your file location"
End Sub
example of results:
SHOULD BE: (JUST EXAMPLE)
1 2 3 4 5 6 7 8 9 10
What I am getting:
9 10 1 2 3 4 5 6 7 8 9 10