Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Save workbook with a predefined name

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete workbook from one location and save workbook to new locatio Damien Excel Programming 5 August 3rd 06 03:05 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Using interop.excel to open a workbook, the workbook doesn't ask to save changes. [email protected] Excel Programming 1 December 28th 05 10:23 PM
Cycling through predefined worksheets Craig M Excel Programming 3 July 1st 04 07:58 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"