|
For X = 1 To 3
.NewSearch ← これ入れてみたらどうでしょうか?
(実際のファイル名がわからないので未確認)
If X = 1 Then
.Filename = 商品 & "_*-.xls"
ElseIf X = 2 Then
.Filename = 商品 & ".xls"
ElseIf X = 3 Then
.Filename = 商品 & "*_.xls"
End If
If .Execute > 0 Then
For U = 1 To 1
Target = .FoundFiles(U)
Target2 = Right(Target, Len(Target) - InStrRev(Target, "\"))
Name Target As MyFolder2 & Target2
Next U
Exit For
End If
Next X
//////////////
Else
.NewSearch ←
RANK = Right(Cells(i, 3), 1)
.Filename = 商品 & "*" & RANK & ".xls"
If .Execute > 0 Then
For U = 1 To 1
Target = .FoundFiles(U)
Target2 = Right(Target, Len(Target) - InStrRev(Target, "\"))
Name Target As MyFolder2 & Target2
Next U
End If
End If
End With
|
|