![]() |
Save As Macro
I am running the following sub routine, but I would like the new file name to
incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
Hi,
SaveAs is an illegal sub name. Try this for your saveas line ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\" & Range("A2").Value & Range("A3").Value & "\MyFile.xls" Mike "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
yyyy = Range("A2").Value
mmyyyy = Range("A3").Value ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
Range("A2") is a date and I want to use just the year from it for yyyy. I
tried this Text(Year(Range("B6").Value), "0000") but received an error. Also, Range("A3") is a date which I want to be month-year for mmyyyy. I tried this Text(Range("B6").Value), "mm-yyyy") but received an error. any suggestions? "Mike" wrote: yyyy = Range("A2").Value mmyyyy = Range("A3").Value ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
My first attempt at a simple VBA action. This post made it possible. Was
trying to figure out how to save as based on the value in a cell, and this did the trick. Thanks a ton. -Liver "Mike" wrote: yyyy = Range("A2").Value mmyyyy = Range("A3").Value ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
Sub doit()
yyyy = Format(Range("A2").Value, "yyyy") mmyyyy = Format(Range("A3").Value, "mm-yyyy") ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" End Sub "iperlovsky" wrote: Range("A2") is a date and I want to use just the year from it for yyyy. I tried this Text(Year(Range("B6").Value), "0000") but received an error. Also, Range("A3") is a date which I want to be month-year for mmyyyy. I tried this Text(Range("B6").Value), "mm-yyyy") but received an error. any suggestions? "Mike" wrote: yyyy = Range("A2").Value mmyyyy = Range("A3").Value ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
Save As Macro
Try this:
MyYear = Year(Range("A2").Value) mmYY = Format((Range("A3").Value), "mm-yyyy") MySaveAsFileName = "N:\FOLDER1\" & MyYear & "\" & mmYY & "\MyFile.xls" ActiveWorkbook.SaveAs Filename:=MySaveAsFileName Regards, Per "iperlovsky" skrev i meddelelsen ... Range("A2") is a date and I want to use just the year from it for yyyy. I tried this Text(Year(Range("B6").Value), "0000") but received an error. Also, Range("A3") is a date which I want to be month-year for mmyyyy. I tried this Text(Range("B6").Value), "mm-yyyy") but received an error. any suggestions? "Mike" wrote: yyyy = Range("A2").Value mmyyyy = Range("A3").Value ActiveWorkbook.SaveAs Filename:="C:\FOLDER1\" & yyyy & "\" & mmyyyy & "\MyFile.xls" "iperlovsky" wrote: I am running the following sub routine, but I would like the new file name to incorporate a specific cell value so that the file will always be saved in the most current folder. Sub SaveAs() ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\MyFile.xls" End Sub For example, in the modified code below I would like folders {yyyy} and {mm-yyyy} to reference cells A2 and A3, respectively, in a specific worksheet in the active workbook. ActiveWorkbook.SaveAs Filename:="N:\FOLDER1\{yyyy}\{mm-yyyy}\MyFile.xls" Thanks for the help, IP |
All times are GMT +1. The time now is 12:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com