Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy/paste selected worksheets

Let me see if I can explain this a little better. I connected th
function that you have given me to a command button so that when it i
clicked in the master workbook it will prompt for a six digit shippin
number...take that number and create a workbook with the date and tha
number. That was the hard part for me. But now I don't know where t
put the line to copy the highlighted worksheets in the master book an
paste them to the newly created shipping workbook, or if it is eve
possible due to the variable name. I do hundreds of these a day s
this will be a great help if I don't have to manually drag and drop.

Thanks,
Mjac

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default copy/paste selected worksheets

Are "highlighted" worksheets the ones that are selected (grouped)?

if yes:

Option Explicit
Sub testme()

Dim myStr As String
Dim newWkbk As Workbook

Do
myStr = InputBox(prompt:="Enter a 6 digit number")
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

'create the new workbook code here
ActiveWindow.SelectedSheets.Copy 'copies to a new workbook

Set newWkbk = ActiveWorkbook

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

newWkbk.Close savechanges:=False

End Sub



"mjack003 <" wrote:

Let me see if I can explain this a little better. I connected the
function that you have given me to a command button so that when it is
clicked in the master workbook it will prompt for a six digit shipping
number...take that number and create a workbook with the date and that
number. That was the hard part for me. But now I don't know where to
put the line to copy the highlighted worksheets in the master book and
paste them to the newly created shipping workbook, or if it is even
possible due to the variable name. I do hundreds of these a day so
this will be a great help if I don't have to manually drag and drop.

Thanks,
Mjack

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


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy/paste selected worksheets

Thanks Dave! It works great, just what I need. Thank you for your
patience.


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

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
copy selected rows to second worksheet (NOT Cut + Paste) gyrra New Users to Excel 2 June 4th 10 09:05 PM
Macro to copy & paste-special-values data to selected worksheets tomhelle Excel Discussion (Misc queries) 1 May 5th 10 02:00 PM
copy only selected worksheets CC Excel Discussion (Misc queries) 1 October 9th 08 06:57 PM
How I can copy / paste a selected cells to other columns in Excel M.Rafat Excel Discussion (Misc queries) 4 November 7th 06 05:42 AM
How to Copy & Paste selected Range in Excel (MFC) Daniel Xu Excel Programming 6 November 25th 03 02:42 AM


All times are GMT +1. The time now is 10:14 AM.

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"