I have a problem with Excek VBA. The following part of my code returns the error code "End If without block If". But I can not see why. I searched the internet, but still can not find what the problem is. About the code: I want to open two folders and find the file in folder 1 (Controlfolder) with the filename containing the string "ROI_3". When found, I want to open it and find the file in the other folder (Treatedfolder) with the name containing "ROI_3". Later, I want to do calculations using data from both files. Below you can see the relevant part of the code.
Do While ControlFile <> ""
If InStr(ControlFile, "ROI_3") > 0 Then
Workbooks(ControlFile).Open
Exit Do
TreatedFile = Dir(TreatedFolder & "\", vbReadOnly)
Do While TreatedFile <> ""
If InStr(TreatedFile, "ROI_3") > 0 Then
Workbooks(TreatedFile).Open
Exit Do
End If
End If
ControlFile = Dir
Loop
Kind regards
Ferenc
Aucun commentaire:
Enregistrer un commentaire