How to save excel file with incrementing number?

前端 未结 2 1432

I am looking for VBA to add to my macro that will increment the file name if the file name already exists.

Current Code:

Dim filepath As String
Dim          


        
2条回答
  •  醉话见心
    2021-01-07 15:11

    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
    

提交回复
热议问题