每次使用VBA在excel 2010中以不同的名称保存文件 [英] Using VBA to save a file in excel 2010 with a different name each time
问题描述
我有一个电子表格,我将其用作模板来获取用户输入.当您按下电子表格上的提交"按钮时,它将数据发送到另一个工作簿,该工作簿存储所有先前的条目,然后清除模板.按下按钮时,是否可以将模板另存为其他文件?我知道.Saveas(),但是我想要一个基于在单元格A2和B2中键入的文件名吗?
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?
推荐答案
我每天执行此操作,将文件保存为前几天.我修改了我想要的东西:
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
这篇关于每次使用VBA在excel 2010中以不同的名称保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!