Hi everyone!

I'm not a programmer, but I'm trying to create a function that copy a range of cells from a sheet in a workbook to a new workbook as values, but with the same cells format.
In the same function, I would like to have the option of saving the sheet in a complete new workbook, or open an existing one, and add the new sheet.
Is this possible to do in VBA???
Here's the code I've done so far, but it only saves the sheet into a new file:
[vba]
Sub Save_CostSheet()
Dim NewFileName As String
Dim NewTitle As String
Dim SheetName As String
Dim CurrentBook As Workbook
Dim CurrentSheet As Worksheet
'Name of the cost sheet title.
NewTitle = InputBox("Please Specify the Title for this Cost Sheet", "New Cost Sheet")
If NewTitle = "False" Or NewTitle = "" Then
Exit Sub
End If
'Getting the name of the new file.
NewFileName = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xls), *.xls", Title:="Save As")
If NewFileName = "False" Or NewTitle = "" Then
Exit Sub
End If
'Saving sheet name and copy.
SheetName = ActiveSheet.Name
Sheets(SheetName).Copy
'Saving the new file with selected sheet.
If LCase$(Right$(NewFileName, 4)) <> ".xls" Then
NewFileName = NewFileName & ".xls"
End If
Set CurrentBook = ActiveWorkbook
With CurrentBook
If NewFileName <> "False" Then
Set CurrentSheet = ActiveSheet
With CurrentSheet
.Range("A1").Value = NewTitle
End With
.SaveAs NewFileName
.Close
Else
.Close False
Exit Sub
End If
End With
End Sub
[/vba]

This code as also a problem with the file created. Everytime I open the new file, a message popup saying that the file is in a different format than specified by the file extension. Does anyone knows how to avoid this?

Thanks by the help!!!