|
楼主 |
发表于 2024-1-29 20:56
来自手机
|
显示全部楼层
ykcbf1100 发表于 2024-1-29 20:12
上附件吧,这样空对空说不清楚。
感谢老师热心帮助。出租屋没电脑,上传不了附件。只有手机上敲的代码。如下:
Sub dsh()
Dim dic As New Dictionary
Dim arr, arr1, m
Dim s As WorkSheet
Dim z%, x%, y%, j%
Application.ScreenUpdating = False
arr = Sheets(1). UsedRange
For z = 1 To UBound(arr)
dic(arr(z, 1)) = Sheets(1) & "|" & z
Next
For x = 2 to Sheets.Count - 1
arr1 = Sheets(x). UsedRange
For y = 1 To UBound(arr1)
If dic. Exists(arr1(y, 4)) Then
dic(arr1(y, 4)) = Sheets(x) & "|" & y
End If
Next
Next
For Each m in dic. Items
s = Split(m, "|")(0)
j = Split(m, "I")(1)
If s <> Sheets(1) Then
s. Cells(j, 7) = "文本我1"
s. Cells(j, 9) = "文本2"
Else: s. Cells(j, 2) = "未找到"
End If
Next
Application.ScreenUpdating = True
End Sub
我的代码肯定是有问题的。我的设想是找到关键字最后出现的位置,并修改相应的值。我觉得借用3楼老师那个设定可以解决。 |
|