Hi Guys, So I am using this to simplify our stock takes. Our scanners dock and download the counts in a text document. The program only writes to one file named CIPHER.OUT.txt we use multiple scanners. so after every download, it rewrites the .txt file with the last download. So I have to import the .txt data into excel every time before I dock and Download the new scanner. Importing the data is not to difficult, but I need the new import to add to the end of the data in excel.
This is the vba I use to import the .txt file data
Sub ImportTextFileToExcel()
Dim textFileNum, rowNum, colNum As Integer
Dim textFileLocation, textDelimiter, textData As String
Dim tArray() As String
Dim sArray() As String
textFileLocation = "C:\Users\200327\Desktop\CIPHER.OUT.txt"
textDelimiter = "|"
textFileNum = FreeFile
Open textFileLocation For Input As textFileNum
textData = Input(LOF(textFileNum), textFileNum)
Close textFileNum
tArray() = Split(textData, vbLf)
For rowNum = LBound(tArray) To UBound(tArray) - 1
If Len(Trim(tArray(rowNum))) <> 0 Then
sArray = Split(tArray(rowNum), textDelimiter)
For colNum = LBound(sArray) To UBound(sArray)
ActiveSheet.Cells(rowNum + 2, colNum + 1) = sArray(colNum)
Next colNum
End If
Next rowNum
End Sub
this is what it looks like after the import into excel
With the second scanner data that has over written the CIPHER.OUT.txt I want to import the new data without replacing the data in excel, but it should onlu add (in this example from row 9)
Lets assume the next data will occupy the row up until row 50. the 3rd scanner data should be added from row 51 if it makes sence. Please help
This is the vba I use to import the .txt file data
Sub ImportTextFileToExcel()
Dim textFileNum, rowNum, colNum As Integer
Dim textFileLocation, textDelimiter, textData As String
Dim tArray() As String
Dim sArray() As String
textFileLocation = "C:\Users\200327\Desktop\CIPHER.OUT.txt"
textDelimiter = "|"
textFileNum = FreeFile
Open textFileLocation For Input As textFileNum
textData = Input(LOF(textFileNum), textFileNum)
Close textFileNum
tArray() = Split(textData, vbLf)
For rowNum = LBound(tArray) To UBound(tArray) - 1
If Len(Trim(tArray(rowNum))) <> 0 Then
sArray = Split(tArray(rowNum), textDelimiter)
For colNum = LBound(sArray) To UBound(sArray)
ActiveSheet.Cells(rowNum + 2, colNum + 1) = sArray(colNum)
Next colNum
End If
Next rowNum
End Sub
this is what it looks like after the import into excel
With the second scanner data that has over written the CIPHER.OUT.txt I want to import the new data without replacing the data in excel, but it should onlu add (in this example from row 9)
Lets assume the next data will occupy the row up until row 50. the 3rd scanner data should be added from row 51 if it makes sence. Please help