我有兩個文本,格式不一樣,但第一列是一樣的。想從原資料中刪去洗掉集中存有的資料(只按每行前11位數進行對比),結果生成新的資料檔案。求大神幫忙寫個VB陳述句。
按前11位對比,不是要按分隔符。
最好用VBA,不要VBs
uj5u.com熱心網友回復:
文本必須是ANSI編碼Sub demo()
Dim d As Object, temp As String
Set d = CreateObject("scripting.dictionary")
Open "C:\Users\洗掉集.txt" For Input As #1
Line Input #1, temp
Do Until EOF(1)
Line Input #1, temp
d(Left(temp, 11)) = ""
Loop
Close #1
Open "C:\Users\源資料.txt" For Input As #1
Open "C:\Users\結果.txt" For Output As #2
Line Input #1, temp
Print #2, temp
Do Until EOF(1)
Line Input #1, temp
If Not d.exists(Left(temp, 11)) Then
Print #2, temp
End If
Loop
Close #1, #2
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/177207.html
標籤:VBA
上一篇:VBA## on error go to多次跳轉問題## 求教
下一篇:專案微管理42 - 人本
