How to save excel file with incrementing number?

北城余情 提交于 2019-12-01 01:50:28

Someone suggested this and it worked for me:

Dim filecount As Integer

Do While Len(Dir(filepatharch & thfilename)) <> 0
        filecount = filecount + 1
        filedate = Format(Now, "MMDD0" & filecount & ".")
        tdfilename = "TD" & filedate & filelist
        thfilename = "TH" & filedate & filelist
Loop

Just put a conditional loop with Dir()

Do While ((Dir(filepath & tdfilename)) <> Empty)
inc = inc+1
filedate = Format(Now, "MMDD") & "." & Format(inc, "00")
tdfilename = "TD" & filedate & filelist
Loop
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!