Sub the delete ()
Dim xlsfile, ar (), n %
Dim xls_ar ()
Xlsfile=Dir (" D: \ common file \ "& amp; "*.jpg")
Do Until Len (xlsfile)=0
N=n + 1
ReDim Preserve ar (1 To n)
Ar (n)=xlsfile
Xlsfile=Dir
Loop
Xls_ar=Range (C10884: "C" & amp; [C65535]. End (3). The Row)
Dim c
The Set dic=CreateObject (" scripting. The dictionary ")
For Each c In xls_ar
Dic (c)=""
Next
For I=1 To UBound (ar) - LBound (ar) + 1
If dic. The exists (ar) (I) Then
Dim filename As String
Filename=Dir (" D: \ common file \ "& amp; Ar (I) & amp; ". JPG ")
Kill "D: \ common file " & amp; Filename
Filename=Dir
End the If
Next
End Sub
My confusion is the filename=Dir (" D: \ common file \ "& amp; Ar (I) & amp; ". JPG ")
Because the program won't be able to identify ar (I) he will go to find the variable name ar (I), rather than the value of the inside, it's strange
I don't know whether this need references or something? Please god to give me some advice and help, I started learning VBA today
CodePudding user response:
Ar (I) have the suffix. JPG, in your filename=Dir (" D: \ common file \ "& amp; Ar (I) & amp; ". JPG ") one more time. JPG