I've seen similar problems here, I've researched in several blogs but I still can't find a solution. I'm trying to automatically create a name for a file based in some cells.
So, I created a macro which aims to do :
Copy / Paste as values all the info I want to save (that's because some cells are based in dynamic formulas as for instance NOW());
"Save as" the file, trying to use the information defined in one specific cell of the file.
My macro looks like this:
Sub SaveMyWorkbook()
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Parameters").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Demande d'Achat").Select
Range("S3:U3").Select
Application.CutCopyMode = False
Dim strPath As String
Dim strFolderPath As String
strFolderPath = "\\camo106\remote\Achat_Purchasing\Demande d'achat_Purchase request\2019\"
strPath = strFolderPath & _
Parameters.Range("D1").Value & ".xlsm"
ActiveWorkbook.SaveAs Filename:=strPath,
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
However, when I debug there is always a problem in the line in which I try to create the name:
strPath = strFolderPath & _ Parameters.Range("D1").Value & ".xlsm"
Could anyone help me? I'm not at all an advanced user of macros, and I guess that this one is far away from my knowledge.
I'm using Excel 2010.