View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mjack003 mjack003 is offline
external usenet poster
 
Posts: 1
Default copy/paste selected worksheets

Hi,

I have this function that will create and save the workbook under the
name input by the user. Now, I need to enter a copy/paste function
somewhere in there that will copy the the selected worksheets in the
master workbook and paste them into the newly created workbook. This
might be simple but I can't figure this one out. Thanks in advance.
What I have is this:

Private Sub CommandButton1_Click()

Dim myStr As String
Dim newWkbk As Workbook

Do
myStr = InputBox(prompt:="Enter PO# :")
If Trim(myStr) = "" Then
Exit Sub ' or what??
End If

If IsNumeric(myStr) Then
If Val(myStr) = CLng(myStr) _
And Val(myStr) < 999999 Then
myStr = Format(Val(myStr), "000000")
Exit Do
End If
End If
Loop

Set newWkbk = Workbooks.Add(1)

newWkbk.SaveAs Filename:=ThisWorkbook.Path & "J:\Rec_Share\Customers
for Shipping\" _
& "PO# " & myStr & " " & Format(Date, "(mm-dd-yy)") & ".xls", _
FileFormat:=xlWorkbookNormal


End Sub

Best Regards,
Mjack


---
Message posted from http://www.ExcelForum.com/