|
更新代码。。。- Sub test8() '//2024.2.28
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- p = ThisWorkbook.Path & ""
- Call test3
- Set wb = Workbooks.Open(p & "测试.txt", 0)
- With wb.Sheets(1)
- zrr = .UsedRange
- End With
- wb.Close 0
- For i = 2 To UBound(zrr)
- s = Left(zrr(i, 1), 6)
- d1(s) = Right(zrr(i, 1), 1)
- Next
- Set wb = Workbooks.Open(p & "原有内容.txt", 0)
- With wb.Sheets(1)
- r = .Cells(Rows.Count, 1).End(3).Row
- r1 = .Columns("a:a").Find("[LINK]", , , , , 1).Row
- ar = .Range("a1:a" & r1 - 1)
- br = .Range(.Cells(r1, 1), .Cells(r, 1))
- End With
- wb.Close 0
- ReDim brr(1 To 1000, 0)
- For i = 1 To UBound(ar)
- s = Left(ar(i, 1), 6)
- m = m + 1
- If d1.exists(s) Then
- brr(m, 0) = s & "=" & d1(s)
- Else
- brr(m, 0) = ar(i, 1)
- End If
- Next
- On Error Resume Next
- st = ""
- For i = 2 To UBound(brr)
- s = Left(brr(i, 0), 6)
- If d1.exists(s) Then
- st = st & "|" & s
- End If
- Next
- For i = 2 To UBound(zrr)
- s = Left(brr(i, 0), 6)
- If InStr(st, s) = 0 Then
- m = m + 1
- brr(m, 0) = zrr(i, 1)
- End If
- Next
- For i = 1 To UBound(br)
- m = m + 1
- brr(m, 0) = br(i, 1)
- Next
- Set wb = Workbooks.Open(p & "测试.txt", 0)
- With wb.Sheets(1)
- .UsedRange = ""
- .[a1].Resize(m, 1) = brr
- End With
- wb.Close 1
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|