I have an excel with some sheets. I have a macro that I launch from sheet 1 to export the sheet "INFO" into an CSV file.
I have the macro below, but the original excel is somehow "changed" or it's like after the export I'm viewing the exported CSV.
I want that the macro ends with the exported CSV, without modifying / changing the excel I have open.
Sub Export()
Dim DefFileName As String
Dim SaveAsFileName As Variant
'Static variables keeps there values between the calls
If DefFileName = "" Then
'The default file name can contain a path:'m
DefFileName = Environ("USERPROFILE") & "\EXPORT.CSV"
End If
'Ask the user
SaveAsFileName = Application.GetSaveAsFilename( _
DefFileName, "CSV (MS-DOS) (*.csv), *.csv")
If VarType(SaveAsFileName) = vbBoolean Then
'Aborted
Exit Sub
End If
ThisWorkbook.Sheets("INFO").Activate
ActiveWorkbook.SaveAs SaveAsFileName, xlCSVUTF8, CreateBackup:=True, Local:=True
End Sub