Code:
Let Range("A20").Resize((Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ""))) / 2 + 1, (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1) = Application.Index(Split(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ","), ","), 1, _
Evaluate("=COLUMN(A:" & Split(Cells(1, (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1).Address, "$")(1) & ")+((Row(1:" & (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ""))) / 2 + 1 & ")-1)*" & (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1 & ")"))
How much?
Code:
Sub LineLenfTest() ' https://www.excelfox.com/forum/showthread.php/1976-Code-Tag-Test-with-Long-Comments-Code-Window-Horitontal-scroll-bar?p=23291&viewfull=1#post23291https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff?p=23290&viewfull=1#post23290
' Let Range("A20").Resize((Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ""))) / 2 + 1, (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1) = Application.Index(Split(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ","), ","), 1, _
' Evaluate("=COLUMN(A:" & Split(Cells(1, (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1).Address, "$")(1) & ")+((Row(1:" & (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readall, vbCr & vbLf, ""))) / 2 + 1 & ")-1)*" & (Len(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline()) - Len(Replace(CreateObject("scripting.filesystemobject").opentextfile(ThisWorkbook.Path & "\3Row2ColumnTextFile.txt").readline(), ",", ""))) + 1 & ")"))
Dim Str1 As String, Str2 As String
Let Str1 = "Let Range(""A20"").Resize((Len(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readall) - Len(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readall, vbCr & vbLf, """"))) / 2 + 1, (Len(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline()) - Len(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline(), "","", """"))) + 1) = Application.Index(Split(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readall, vbCr & vbLf, "",""), "",""), 1,"
Debug.Print Len(Str1) ' 738
Let Str2 = "Evaluate(""=COLUMN(A:"" & Split(Cells(1, (Len(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline()) - Len(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline(), "","", """"))) + 1).Address, ""$"")(1) & "")+((Row(1:"" & (Len(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readall) - Len(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readall, vbCr & vbLf, """"))) / 2 + 1 & "")-1)*"" & (Len(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline()) - Len(Replace(CreateObject(""scripting.filesystemobject"").opentextfile(ThisWorkbook.Path & ""\3Row2ColumnTextFile.txt"").readline(), "","", """"))) + 1 & "")""))"
Debug.Print Len(Str2) ' 897
End Sub
With only 1023 characters available, then not much chance for improvement here, so forget about this one for now
Bookmarks