Using VBA to save a file in excel 2010 with a different name each time [closed]

烈酒焚心 提交于 2019-12-13 11:15:42

问题


I have a spreadsheet that I'm using as a template to get user input. When you press the submit button on the spreadsheet, it sends the data to a different workbook that stores all the previous entries and then clears the template. Is there a way to save the template as a different file when you push the button? I know about .Saveas(), but I want a file name that's based off what was typed in cell A2 and B2?


回答1:


I do this on a daily basis saving the file as the previous days date. I modified what I use for what you are wanting:

dim name as string

name = Cells(1,2).Value & Cells(2,2).Value

ActiveWorkbook.SaveAs() Filename:=name


来源:https://stackoverflow.com/questions/21897456/using-vba-to-save-a-file-in-excel-2010-with-a-different-name-each-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!