Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
delete workbook from one location and save workbook to new locatio | Excel Programming | |||
Select sheet tabs in workbook & save to separate workbook files | Excel Worksheet Functions | |||
Using interop.excel to open a workbook, the workbook doesn't ask to save changes. | Excel Programming | |||
Cycling through predefined worksheets | Excel Programming | |||
What commands do you use to name a workbook, save a workbook,open a workbook | Excel Programming |