I'm trying to check how many files are in a directory, increment the count each time then put that count in my file name.
I'm having trouble with the loop. I can kinda see what the reason is, it looks like it's not counting each file but possibly saying on the same one. Any ideas from the geniuses out there?
I'm having trouble with the loop. I can kinda see what the reason is, it looks like it's not counting each file but possibly saying on the same one. Any ideas from the geniuses out there?
Code:
If Dir(filePath & custnm & "*.*") <> "" Then
Do Until Dir(filePath & custnm & "*.xlsm") = ""
x = x + 1
Dir
Loop
book.SaveAs Filename:=filePath & custnm & "\" & custnm & " install form" & "v_" & x
Else:
MkDir filePath & custnm
book.SaveAs Filename:=filePath & custnm & "\" & custnm & " install form"
End If