|
▼MIMI さん:
>
>しかし、このコードだと、とても時間がかかってしまう難点があります
例のように規則性があるんでしたら
下記のようでいけそうです。
Sub TESTx()
Dim Dic As Object
Dim v1 As Variant
Dim v2 As Variant
Dim i As Long
With Worksheets("Sheet1")
v1 = .Range("A1").CurrentRegion.Resize(, 2).Value
End With
Set Dic = CreateObject("Scripting.Dictionary")
For i = 2 To UBound(v1)
Select Case Left(v1(i, 1), 1)
Case "*", "?"
Dic(Replace(Replace(Right(v1(i, 1), Len(v1(i, 1)) - 1), "*", "|"), "?", "-")) = v1(i, 2)
Case Else
Dic(Replace(Replace(v1(i, 1), "*", "|"), "?", "-")) = v1(i, 2)
End Select
Next
With Worksheets("Sheet2")
v2 = .Range("A1").CurrentRegion.Resize(, 2).Value
For i = 2 To UBound(v2)
If Dic.Exists(v2(i, 1)) Then
v2(i, 2) = Dic(v2(i, 1))
End If
Next
.Range("A1").Resize(UBound(v2), 2).Value = v2
End With
End Sub
|
|