Sheets(Sheetname).Activate
ActiveWorkbook.SaveAs Filename:="C:\" & ActiveSheet.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False
Application.Sheets(Sheetname).Select
Application.Sheets(Sheetname).Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\" & ActiveSheet.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Save
ActiveWindow.Close
Windows(oldfilename).Activate
Application.DisplayAlerts = True
Sub SendToText()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveWorkbook.Save
FW = Range("thiswk")
LW = Right(Range("'Input Form'!T7"), 2)
SourceFile = ActiveWorkbook.FullName
SourcePath = ActiveWorkbook.Path
DestPath = SourcePath & "\HFM Upload\"
NewFileName = "13 Week Forecast " & FW & "-" & LW & ".txt"
TextFile = DestPath & NewFileName
Msg = MsgBox("HFM Upload file will be created:" & Chr(10) & TextFile, _
vbOKOnly, "Complete")
Sheets("HFM Upload").Select
Range("A1:A14").Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=TextFile, FileFormat:= _
xlText, CreateBackup:=False
Workbooks.Open Filename:=SourceFile, Origin:=xlWindows
Windows(NewFileName).Activate
ActiveWorkbook.Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
You need to affect the current workbook to a variable and he new one ot a variable the you can close which one you like and keep the one you like open.
pls chk the below code
gowflow
Open in new window