Naming File from a Cell
Hi RisingStar,
Try this:
- Open your workbook;
- Right click on tab sheet;
- Click View Code command;
- Insert the code below;
- Now inserting a string on A1 cell the file name will be changed as.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldFileName As String
Dim NewFileName As String
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
NewFileName = Range("A1").Value
NewFileName = Replace(NewFileName, ", ", "_")
OldFileName = ThisWorkbook.FullName
ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & NewFileName & ".xls"
Kill OldFileName
End Sub
HTH
---
Orlando Magalhães Filho
(So that you get best and rapid solution and all may benefit from the
discussion, please reply within the newsgroup, not in email)
"RisingStar" escreveu na mensagem
...
Is it possible to change the name of an excel worksheet and create a new
filename from one of the cells? The source cell is a name in format:
Surname, Firstname
Thanks for your help
MR
|