View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
tmort[_4_] tmort[_4_] is offline
external usenet poster
 
Posts: 1
Default Save As File Control


I found anothe thread in this forum on saving a single sheet. Below i
the code that I am using along with the getfilename function:

Private Sub CommandButton16_Click()


Set wkb = Workbooks.Add
ThisWorkbook.Sheets("sheetname").Copy Befo=wkb.Sheets(1)
Application.DisplayAlerts = False
For i = wkb.Sheets.Count To 2 Step -1
' Delete all but the 1st sheet
wkb.Sheets(i).Delete
Next i
Application.DisplayAlerts = True

wkb.SaveAs gsGetFilename

wkb.Close



End Sub

The first part makes a copy of the sheet named sheetname and puts it i
a new workbook, then it deletes all other sheets. I use the last lin
to close the new one sheet workbook and go back to the orgina
workbook.

A simpler way is to just use:

Worksheets("Sheet1").Copy which copies the sheet to a new single shee
workbook which will then be the active sheet.

Based on the thread I mentioned the I chose to use the longer method a
according to one poster the second method is an undocumented method

--
tmor
-----------------------------------------------------------------------
tmort's Profile: http://www.excelforum.com/member.php...fo&userid=2105
View this thread: http://www.excelforum.com/showthread.php?threadid=38907