Macro VBA code to name Save-As file
Assuming your cells don't have illegal characters - i.e., characters that
Windows won't allow in a filename - then
Dim strFileName as String
strFileName = "c:\Filename " & range("C1").Text & " " & range("I1").Text &
".xls"
Then use your first syntax below but with
Filename:=strFileName
STANDARD SOAPBOX COMMENT -
Try to never use merged cells. The screw up sorting and selecting ranges
and all sorts of stuff. You can accomplish most of the same things that
merging 'offers' you by Centering Across Selection or by using Text Boxes
"Dolores" wrote:
Hi,
The following code works to name a Save_As file (but I want to add data from
two cells to the name of the file):
ActiveWorkbook.SaveAs Filename:= _
"C:\Filename.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
I want the complete file name to be made up of :
"C:\Filename " & <the string of data from merged cell C1:E1 & €ś €ś &
<the string of data from cell I1 & ".xls" _
I dont seem to be able to retrieve data from the cells in a format that
doesnt generate error messages like €śMismatch,€ť €śExpected expression,€ť or
€śSub or Function not defined.€ť
I have exhausted all of my ideas and would appreciate any suggestions.
--
Dolores
|