In support of this main forum Thread
https://excelfox.com/forum/showthrea...nto-excel-cell
_2) save new serial number to csv file below last numbers.



Before :
text File
Code:
TTR0000001
TTR0000002
TTR0000003
Excel File
_____ Workbook: SerialNumbers.xls ( Using Excel 2007 32 bit )
Row\Col
A
B
C
1
Serial# : TTR0000001
2
TTR0000002
3
TTR0000003
4
TTR0000004
5
Worksheet: Sheet1


Run this macro
Code:
'    https://excelfox.com/forum/showthread.php/2797-find-last-alphanumeric-row-of-txt-file-and-fill-into-excel-cell
Sub SaveLatestSNinTextFile()
Rem 1 Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1)                                    ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
 Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "serial_number.csv"   '
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
' Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
'Get #FileNum, , TotalFile
'  Or  http://www.eileenslounge.com/viewtopic.php?p=295782&sid=f6dcab07c4d24e00e697fe4343dc7392#p295782
 Let TotalFile = Input(LOF(FileNum), FileNum)
Close #FileNum

Rem 2 get latest serial nimber from Excel file
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1)
Dim LrB As Long: Let LrB = Ws1.Range("B" & Ws1.Rows.Count & "").End(xlUp).Row
Dim CrntNmbr As String: Let CrntNmbr = Ws1.Range("B" & LrB & "").Value

Rem 3 add latest serial number to text file
' 3a  add a new line and the latest serial number to the string of the entire file
    If Right(TotalFile, 2) = vbCr & vbLf Then Let TotalFile = Left(TotalFile, Len(TotalFile) - 2)
 Let TotalFile = TotalFile & vbCr & vbLf & CrntNmbr  '
' 3b  replace the text file with the new string
Dim FileNum2 As Long: Let FileNum2 = FreeFile(0)                                  ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
 Open PathAndFileName For Output As #FileNum2
 Print #FileNum2, TotalFile ' write out entire text file
 Close #FileNum2
End Sub

After:
Code:
TTR0000001
TTR0000002
TTR0000003
TTR0000004