ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Saving file in the format "YYMM" (https://www.excelbanter.com/excel-discussion-misc-queries/48635-saving-file-format-%22yymm%22.html)

Dolphinv4

Saving file in the format "YYMM"
 
Hi,

I am trying to get a macro to extract a date from a cell (A1), then save the
file in the format "YYMM Forecast".

May I know what is the code I should type in?

I tried the following but it doesn't work:

Dim myMonth as String
Dim myFileName as String

myMonth = Format("H71:J71", "yymm")
myFileName = "C:\" & myMonth & " Forecast.xls"

ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal

Thanks.


Dan

There is a "Range" missing in the code.

myMonth = Format(Range("H71"), "yymm")

"Dolphinv4" wrote:

Hi,

I am trying to get a macro to extract a date from a cell (A1), then save the
file in the format "YYMM Forecast".

May I know what is the code I should type in?

I tried the following but it doesn't work:

Dim myMonth as String
Dim myFileName as String

myMonth = Format("H71:J71", "yymm")
myFileName = "C:\" & myMonth & " Forecast.xls"

ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal

Thanks.


Dave Peterson

And why do you have 3 cells in your range:

myMonth = Format("H71:J71", "yymm")

That may affect the answer.

Dolphinv4 wrote:

Hi,

I am trying to get a macro to extract a date from a cell (A1), then save the
file in the format "YYMM Forecast".

May I know what is the code I should type in?

I tried the following but it doesn't work:

Dim myMonth as String
Dim myFileName as String

myMonth = Format("H71:J71", "yymm")
myFileName = "C:\" & myMonth & " Forecast.xls"

ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal

Thanks.


--

Dave Peterson


All times are GMT +1. The time now is 08:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com