Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to save just the active sheet in excel? 2

Status
Not open for further replies.

coolcarls

Technical User
Jan 19, 2002
182
US
I have a workbook with a bunch of stuff in and the file size is quite large, I want to save JUST the sheet I am woking on as it's own workbook.
I hope it is possible
Carl
 
Right click on the sheet tab > Move/ Copy > Move to a new workbook.

Select new workbook, delete all sheets except the one you copied over > Save as Workbook.
 
Thanks for the answer Bryan, I am afraid that I was unclear in my question. I was looking at automating the process with a module or something, any ideas on that?
 
Put this in the Personal.xls code module then assign a command button for it on the toolbar:

Code:
Sub Copy_Sheet()
Dim sht_name As String, filesavename As Variant, clean_str As String, i As Integer
On Error GoTo bad_name
sht_name = Application.InputBox(Prompt:="Enter Name for Copied Sheet", Type:=2)
ActiveSheet.Copy
ActiveSheet.Name = sht_name
filesavename = Application.GetSaveAsFilename(initialfilename:=ActiveSheet.Name, _
                                                filefilter:="Excel Workbook (*.xls), *.xls")
If filesavename <> &quot;&quot; And filesavename <> False Then: ActiveWorkbook.SaveAs Filename:=filesavename
Exit Sub
bad_name:
    If Len(sht_name) = 0 Then: sht_name = Application.UserName & &quot;~&quot; & Day(Date) & &quot;.&quot; & _
                                         Month(Date) & &quot;.&quot; & Year(Date)
    If Len(sht_name) > 31 Then: sht_name = Left(sht_name, 31)
    For i = 1 To Len(sht_name)
        Select Case Asc(Mid(sht_name, i, 1))
            Case 42, 47, 58, 63, 91 To 93
                'do nothing
            Case Else
                clean_str = clean_str & Mid(sht_name, i, 1)
            End Select
        Next
        sht_name = clean_str
        Resume
End Sub

I've tried it out and it should be foolproof, but let me know if you have any problems.

Bryan. ::)
 
By the way, if you want to remove the active sheet from the workbook, as well as copying it to another workbook, then use
Code:
Activesheet.Move
instead of
Code:
ActiveSheet.Copy
 
Bryan,

GOOD contribution to have on hand. ====> STAR. Thanks. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Bryan
Is there any way to have the new workbook not open when saved?
What's happening is that I hit the save button (which works incredibly well) and the sheet is saved and openned, is it possible to have it not open and just stay with the workbook I am working on?
I will post this as a new question as well.
Thanks
 
Carl:

Use:

Code:
ActiveWorkbook.Close(SaveChanges:=True, FileName:=filesavename)

Instead of:

Code:
ActiveWorkbook.SaveAs Filename:=filesavename

This should get you back to the original workbook. But since I haven't tried it myself, let me know if you have any probs.

Bryan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top