在注意一下紅色部份,做適當的修改!
Sub demo()
Set d = CreateObject("Scripting.Dictionary")
Set f = CreateObject("ADODB.Stream")
a = Sheet1.UsedRange
For i = 2 To UBound(a)
d(a(i, 9) & ".txt") = i
Next
Path = ThisWorkbook.Path & "\有效期\"
file = Dir(Path & "*.txt")
Do Until file = ""
Key = Right(file, 15)
If d(Key) = 0 Then GoTo 1
f.Charset = "utf-8": f.Open
f.LoadFromFile Path & "\" & file
v1 = Split(f.ReadText(-2), ":")
v2 = Split(f.ReadText(-2), ":")
v3 = Split(f.ReadText(-2), ":")
If UBound(v1) = 1 Then a(d(Key), 8) = v1(1) & "-" & v3(1)
f.Close
1:
file = Dir()
Loop
[a1].Resize(UBound(a), UBound(a, 2)) = a
End Sub
祝順心,南無阿彌陀佛!