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 Worksheet to new Workbook and naming

Good evening, All. I'm trying to set up a macro that I can use a radio
button for.

The Macro would take a worksheet entitled "Summary Sheet" and copy values
and formats to a new workbook. I'd like to have the new workbook named based
upon the concantination of values in cells B4 and B6 on the source worksheet,
such as 500_200707. I've searched this site, but didn't find what I needed
(or didn't seach with the right phrasing. Any thoughts?

I believe I can step through a macro to do most of this, but especially do
not understand how to name the new workbook in the macro of the source
workbook. Thanks for any advise or reference. -Bill E.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy Worksheet to new Workbook and naming

Many thanks, Gary! It works well, except I'd like to only have the "Summary
Sheet" copied over, not the whole workbook. Can that be done only keeping
the "Summary Sheet" worksheet values and format in the new workbook? I do
not want any links to the source workbook.

I really need to take a class in this! -Bill

"Gary Keramidas" wrote:

something like this may get you started. kind of late here.

Dim fPath As String
Dim fName As String
Dim ws As Worksheet
Set ws = Worksheets("Summary Sheet")
fPath = ThisWorkbook.Path & "\"
fName = ws.Range("B4").Value & ws.Range("B6").Value & ".xls"

ActiveWorkbook.SaveAs Filename:=fPath & fName

--


Gary


"Bill E" <Bill wrote in message
...
Good evening, All. I'm trying to set up a macro that I can use a radio
button for.

The Macro would take a worksheet entitled "Summary Sheet" and copy values
and formats to a new workbook. I'd like to have the new workbook named based
upon the concantination of values in cells B4 and B6 on the source worksheet,
such as 500_200707. I've searched this site, but didn't find what I needed
(or didn't seach with the right phrasing. Any thoughts?

I believe I can step through a macro to do most of this, but especially do
not understand how to name the new workbook in the macro of the source
workbook. Thanks for any advise or reference. -Bill E.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Copy Worksheet to new Workbook and naming


bill:

this is one way, see how this works for you.


Sub Copy_Summary()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim fPath As String
Dim fName As String

Set ws = Worksheets("Summary Sheet")
Set ws2 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
fPath = ThisWorkbook.Path & "\"
fName = ws.Range("B4").Value & ws.Range("B6").Value & ".xls"

Application.ScreenUpdating = False
ws.Cells.Copy
With ws2.Range("A1")
.PasteSpecial (xlPasteValues)
.PasteSpecial (xlPasteFormats)
End With

Application.DisplayAlerts = False
Worksheets(Worksheets.Count).Select
ActiveWindow.SelectedSheets.Copy
ActiveWorkbook.SaveAs Filename:=fPath & fName
ActiveWorkbook.Close
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
MsgBox fName & " saved in " & fPath
Application.ScreenUpdating = True
End Sub



--


Gary


"Bill E" wrote in message
...
Many thanks, Gary! It works well, except I'd like to only have the "Summary
Sheet" copied over, not the whole workbook. Can that be done only keeping
the "Summary Sheet" worksheet values and format in the new workbook? I do
not want any links to the source workbook.

I really need to take a class in this! -Bill

"Gary Keramidas" wrote:

something like this may get you started. kind of late here.

Dim fPath As String
Dim fName As String
Dim ws As Worksheet
Set ws = Worksheets("Summary Sheet")
fPath = ThisWorkbook.Path & "\"
fName = ws.Range("B4").Value & ws.Range("B6").Value & ".xls"

ActiveWorkbook.SaveAs Filename:=fPath & fName

--


Gary


"Bill E" <Bill wrote in message
...
Good evening, All. I'm trying to set up a macro that I can use a radio
button for.

The Macro would take a worksheet entitled "Summary Sheet" and copy values
and formats to a new workbook. I'd like to have the new workbook named
based
upon the concantination of values in cells B4 and B6 on the source
worksheet,
such as 500_200707. I've searched this site, but didn't find what I needed
(or didn't seach with the right phrasing. Any thoughts?

I believe I can step through a macro to do most of this, but especially do
not understand how to name the new workbook in the macro of the source
workbook. Thanks for any advise or reference. -Bill E.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy Worksheet to new Workbook and naming

Awsome, Gary! Thanks for the help. If you get to San Francisco, I'll
ante-up for a pint of Guinness. -Bill

"Gary Keramidas" wrote:


bill:

this is one way, see how this works for you.


Sub Copy_Summary()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim fPath As String
Dim fName As String

Set ws = Worksheets("Summary Sheet")
Set ws2 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
fPath = ThisWorkbook.Path & "\"
fName = ws.Range("B4").Value & ws.Range("B6").Value & ".xls"

Application.ScreenUpdating = False
ws.Cells.Copy
With ws2.Range("A1")
.PasteSpecial (xlPasteValues)
.PasteSpecial (xlPasteFormats)
End With

Application.DisplayAlerts = False
Worksheets(Worksheets.Count).Select
ActiveWindow.SelectedSheets.Copy
ActiveWorkbook.SaveAs Filename:=fPath & fName
ActiveWorkbook.Close
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
MsgBox fName & " saved in " & fPath
Application.ScreenUpdating = True
End Sub



--


Gary


"Bill E" wrote in message
...
Many thanks, Gary! It works well, except I'd like to only have the "Summary
Sheet" copied over, not the whole workbook. Can that be done only keeping
the "Summary Sheet" worksheet values and format in the new workbook? I do
not want any links to the source workbook.

I really need to take a class in this! -Bill

"Gary Keramidas" wrote:

something like this may get you started. kind of late here.

Dim fPath As String
Dim fName As String
Dim ws As Worksheet
Set ws = Worksheets("Summary Sheet")
fPath = ThisWorkbook.Path & "\"
fName = ws.Range("B4").Value & ws.Range("B6").Value & ".xls"

ActiveWorkbook.SaveAs Filename:=fPath & fName

--


Gary


"Bill E" <Bill wrote in message
...
Good evening, All. I'm trying to set up a macro that I can use a radio
button for.

The Macro would take a worksheet entitled "Summary Sheet" and copy values
and formats to a new workbook. I'd like to have the new workbook named
based
upon the concantination of values in cells B4 and B6 on the source
worksheet,
such as 500_200707. I've searched this site, but didn't find what I needed
(or didn't seach with the right phrasing. Any thoughts?

I believe I can step through a macro to do most of this, but especially do
not understand how to name the new workbook in the macro of the source
workbook. Thanks for any advise or reference. -Bill E.






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 worksheet from one workbook to a master workbook mvannatta Excel Worksheet Functions 3 April 15th 09 08:32 PM
How to Copy entire Worksheet from Workbook S to Workbook D kris Excel Programming 3 June 20th 07 02:03 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 06:55 PM
How do I copy a worksheet form a workbook in my workbook Neil Atkinson Excel Programming 1 October 12th 05 12:23 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM


All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"