Hi Guys
I needed a macro to allow me to save a self populating form that use V Lookups to draw data from a tracker in a separate worksheet into a newly created folder and newly created file.
From couple of online solutions I have managed to create the below macro which works fine but creates some hiccups for me. It seems I need expert advice on how to tweak it.
The key problem is that when I run the macro all the Vlookups remain in the copied files creating links between the newly created form and the main tracker. I would like to tweak the macro that only values are saved (and obviously formats and columns widths) to preserve how the form looks.
2nd issue is that the macro is tied to the button on the spreadsheet which also appears on the newly created forms. Meaning that operators by accident can run the macro of the copy. Therefore I would like to save the file as non macro enabled spreadsheet but when I tried to change extension in the script below it would not work.
Can anyone help please?
Thank you !!!
I needed a macro to allow me to save a self populating form that use V Lookups to draw data from a tracker in a separate worksheet into a newly created folder and newly created file.
From couple of online solutions I have managed to create the below macro which works fine but creates some hiccups for me. It seems I need expert advice on how to tweak it.
The key problem is that when I run the macro all the Vlookups remain in the copied files creating links between the newly created form and the main tracker. I would like to tweak the macro that only values are saved (and obviously formats and columns widths) to preserve how the form looks.
2nd issue is that the macro is tied to the button on the spreadsheet which also appears on the newly created forms. Meaning that operators by accident can run the macro of the copy. Therefore I would like to save the file as non macro enabled spreadsheet but when I tried to change extension in the script below it would not work.
Can anyone help please?
Thank you !!!
VBA Code:
Sub Export_1()
ActiveSheet.Copy 'creates an independent copy of the activesheet
Dim strFilename, strDirname, strPathname, strDefpath As String
On Error Resume Next ' If directory exist goto next line
strDirname = Range("R5").Value ' New directory name
strFilename = Range("R7").Value 'New file name
' strDefpath = Application.ActiveWorkbook.Path 'Default path name
strDefpath = Range("R9").Value
If IsEmpty(strDirname) Then Exit Sub
If IsEmpty(strFilename) Then Exit Sub
MkDir strDefpath & "\" & strDirname
strPathname = strDefpath & "\" & strDirname & "\" & strFilename 'create total string
ActiveWorkbook.SaveAs Filename:=strPathname & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close 'close it and return to original workbook
End Sub