View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Save workbook with a predefined name

Untested.

Dim iPos As Long
Dim sFilename As String
Dim sFilenum As String
Dim iFilenum As Long

sFilename = ActiveWorkbook.Name
iPos = InStr(sFilename, "-")
If Mid(sFilename, iPos + 2, 7) = "student" Then
sFilenum = Mid(sFilename, iPos + 9, Len(sFilename) - iPos - 8)
If IsNumeric(sFilenum) Then
iFilenum = CLng(sFilenum) + 1
sFilename = Left(sFilename, iPos + 8) & iFilenum
Else
sFilename = sFilename & " - student1"
End If
Else
sFilename = sFilename & " - student1"
End If
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & sFilename


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"steven" wrote in message
...
Hi this should be easy.

My workbook has 5 worksheets. I use a macro to delete rows from a
worksheet.
When its done deleting id like to save the workbook with a different name
(in
the same folder where the original workbook is).

the name should be the original workbooks name and " - student1". Can
somebody help me with the code?

Also I'd like to know if - after the new workbook is saved - there is a
way
to revert to the original workbook, delete different rows from the
worksheet
and then save it again with the original workbooks name and " - student2".
Is
this possible?

Any help apriciated.

Steven.