kubek
10-24-2008, 08:10 AM
Hello, i was trying to set the code tahat saves a single shhet (active one or other...) as a excel file. This code however saves all the file so all the sheets why? i have put the restriction: save single sheet and i have done the clue sheet1. But it doesnt play as it shoud.. Any advice?
Sub SaveSingleSheet()
Dim file_name As Variant
' Get the file name.
file_name = Application.GetSaveAsFilename( _
FileFilter:="Excel Files,*.xls,All Files,*.*", _
Title:="Save As File Name")
' See if the user canceled.
If file_name = False Then Exit Sub
' Save the file with the new name.
If LCase$(Right$(file_name, 4)) <> ".xls" Then
file_name = file_name & ".xls"
End If
Worksheets("Sheet1").SaveAs Filename:=file_name
End Sub
Sub SaveSingleSheet()
Dim file_name As Variant
' Get the file name.
file_name = Application.GetSaveAsFilename( _
FileFilter:="Excel Files,*.xls,All Files,*.*", _
Title:="Save As File Name")
' See if the user canceled.
If file_name = False Then Exit Sub
' Save the file with the new name.
If LCase$(Right$(file_name, 4)) <> ".xls" Then
file_name = file_name & ".xls"
End If
Worksheets("Sheet1").SaveAs Filename:=file_name
End Sub