Saving a file based on a cell in the file

PatrickSD

New Member
Joined
Apr 4, 2009
Messages
43
Hello
I have a code that opens a new workbook and saves the a file based on the value of a cell. I am saving it in the current folder.
I made some minor changes and now it won't work.
I can't figure it out.
I would appreciate any help


The following is my code.
Thanks in advance
Sub ()
Application.SheetsInNewWorkbook = 1
Workbooks.Add


ActiveCell.FormulaR1C1 = _
"='[Q1 2015 Aetna MA rev2.xlsm]1. Cover Page'!R100C3"
'REM Range("A1").Select
'REM Selection.Copy
'REM Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


ThisFile = Range("A1").Value


ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & ThisFile, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
On what line do you have an error (although your Sub/Procedure doesn't have a name :) )?
 
Upvote 0
On what line do you have an error (although your Sub/Procedure doesn't have a name :) )?

My problem is the last line.

The program won't save the file

What is strange is that if I change the line
ThisFile = Range("A1").Value
to
ThisFile = "aaa"

The program will save the file to the name aaa.
But with the current code, it won't save the file to the name that is in cell A1.

Sorry, I am still pretty new to this, so I am learning on the fly
 
Upvote 0
WHat do you have in cell A1?, some characters are not allowed in filenames, so maybe check the content of the cell to see
 
Upvote 0

Forum statistics

Threads
1,203,232
Messages
6,054,274
Members
444,713
Latest member
SAK

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top