Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sheets to new WorkBook

Hey there,

What I have done:

Once the user hits the command button, a userform pops up, the users has 4
options to choose(Checkboxes). Say the user selects all 4, it will create 4
new sheets (all named) and copy data from a summary sheet to these newly
created sheets. It sets the format and print area of all 4 sheets. If the
user selects 1 sheets, it will only create one sheets with the desired
information.

Where I want to go from here.

I would like to be able to create a new workbook, copy over the sheets that
have been created then remove the sheets from the orignal workbook. Then I
would like it to promt the user to save the document (if possible, with
SaveAs name set to some I have pre-difined (="Rec Domectic Forecast -
"&summ!E3) to keep a standard naming convention.

Any ideas how this would be done? I can't seem to copy of the sheets since
the new workbook name changes (book(x)).

Thanks,
Rob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sheets to new WorkBook

Try this


Sub test()
Initfile = Sheets("Rec Domectic Forecast - &summ").Range("E3")
Set NewBk = Workbooks.Add
With ThisWorkbook
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
End With
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:=Initfile, _
fileFilter:="Excel Files (*.xls), *.xls")
If fileSaveName < False Then
NewBk.SaveAs Filename:=fileSaveName
End If

"Robert S" wrote:

Hey there,

What I have done:

Once the user hits the command button, a userform pops up, the users has 4
options to choose(Checkboxes). Say the user selects all 4, it will create 4
new sheets (all named) and copy data from a summary sheet to these newly
created sheets. It sets the format and print area of all 4 sheets. If the
user selects 1 sheets, it will only create one sheets with the desired
information.

Where I want to go from here.

I would like to be able to create a new workbook, copy over the sheets that
have been created then remove the sheets from the orignal workbook. Then I
would like it to promt the user to save the document (if possible, with
SaveAs name set to some I have pre-difined (="Rec Domectic Forecast -
"&summ!E3) to keep a standard naming convention.

Any ideas how this would be done? I can't seem to copy of the sheets since
the new workbook name changes (book(x)).

Thanks,
Rob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sheets to new WorkBook

Joel,

Thanks, that worked great.

I have only one issue still... if the user selects all the options, it will
create 5 new sheets and move them over perfectly, however, if the user were
to only choose one, I get an error. Is there an if statement I can use to see
if a sheet exists, if it does, copy it over, if it doesn't, move onto next if
statement.

Thanks again Joel,
Rob

"Joel" wrote:

Try this


Sub test()
Initfile = Sheets("Rec Domectic Forecast - &summ").Range("E3")
Set NewBk = Workbooks.Add
With ThisWorkbook
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
End With
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:=Initfile, _
fileFilter:="Excel Files (*.xls), *.xls")
If fileSaveName < False Then
NewBk.SaveAs Filename:=fileSaveName
End If

"Robert S" wrote:

Hey there,

What I have done:

Once the user hits the command button, a userform pops up, the users has 4
options to choose(Checkboxes). Say the user selects all 4, it will create 4
new sheets (all named) and copy data from a summary sheet to these newly
created sheets. It sets the format and print area of all 4 sheets. If the
user selects 1 sheets, it will only create one sheets with the desired
information.

Where I want to go from here.

I would like to be able to create a new workbook, copy over the sheets that
have been created then remove the sheets from the orignal workbook. Then I
would like it to promt the user to save the document (if possible, with
SaveAs name set to some I have pre-difined (="Rec Domectic Forecast -
"&summ!E3) to keep a standard naming convention.

Any ideas how this would be done? I can't seem to copy of the sheets since
the new workbook name changes (book(x)).

Thanks,
Rob


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sheets to new WorkBook

there are two methods.

Method One
SearchName = "Sheet1"
Found = false
for each sht in worksheets
if sht.name = SearchName then
Found = True
exit for
end if
next sht

if Found = true then
'enter your code here
end if


or

On Error Resume Next
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
On Error GoTo 0


"Robert S" wrote:

Joel,

Thanks, that worked great.

I have only one issue still... if the user selects all the options, it will
create 5 new sheets and move them over perfectly, however, if the user were
to only choose one, I get an error. Is there an if statement I can use to see
if a sheet exists, if it does, copy it over, if it doesn't, move onto next if
statement.

Thanks again Joel,
Rob

"Joel" wrote:

Try this


Sub test()
Initfile = Sheets("Rec Domectic Forecast - &summ").Range("E3")
Set NewBk = Workbooks.Add
With ThisWorkbook
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
End With
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:=Initfile, _
fileFilter:="Excel Files (*.xls), *.xls")
If fileSaveName < False Then
NewBk.SaveAs Filename:=fileSaveName
End If

"Robert S" wrote:

Hey there,

What I have done:

Once the user hits the command button, a userform pops up, the users has 4
options to choose(Checkboxes). Say the user selects all 4, it will create 4
new sheets (all named) and copy data from a summary sheet to these newly
created sheets. It sets the format and print area of all 4 sheets. If the
user selects 1 sheets, it will only create one sheets with the desired
information.

Where I want to go from here.

I would like to be able to create a new workbook, copy over the sheets that
have been created then remove the sheets from the orignal workbook. Then I
would like it to promt the user to save the document (if possible, with
SaveAs name set to some I have pre-difined (="Rec Domectic Forecast -
"&summ!E3) to keep a standard naming convention.

Any ideas how this would be done? I can't seem to copy of the sheets since
the new workbook name changes (book(x)).

Thanks,
Rob


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sheets to new WorkBook

I used the On Error method and it worked like a charm. Thanks for help, it is
much appreciated.

Rob

"Joel" wrote:

there are two methods.

Method One
SearchName = "Sheet1"
Found = false
for each sht in worksheets
if sht.name = SearchName then
Found = True
exit for
end if
next sht

if Found = true then
'enter your code here
end if


or

On Error Resume Next
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
On Error GoTo 0


"Robert S" wrote:

Joel,

Thanks, that worked great.

I have only one issue still... if the user selects all the options, it will
create 5 new sheets and move them over perfectly, however, if the user were
to only choose one, I get an error. Is there an if statement I can use to see
if a sheet exists, if it does, copy it over, if it doesn't, move onto next if
statement.

Thanks again Joel,
Rob

"Joel" wrote:

Try this


Sub test()
Initfile = Sheets("Rec Domectic Forecast - &summ").Range("E3")
Set NewBk = Workbooks.Add
With ThisWorkbook
.Sheets("Sheet1").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets("Sheet2").Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
.Sheets(3).Copy after:=NewBk.Sheets(NewBk.Sheets.Count)
End With
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:=Initfile, _
fileFilter:="Excel Files (*.xls), *.xls")
If fileSaveName < False Then
NewBk.SaveAs Filename:=fileSaveName
End If

"Robert S" wrote:

Hey there,

What I have done:

Once the user hits the command button, a userform pops up, the users has 4
options to choose(Checkboxes). Say the user selects all 4, it will create 4
new sheets (all named) and copy data from a summary sheet to these newly
created sheets. It sets the format and print area of all 4 sheets. If the
user selects 1 sheets, it will only create one sheets with the desired
information.

Where I want to go from here.

I would like to be able to create a new workbook, copy over the sheets that
have been created then remove the sheets from the orignal workbook. Then I
would like it to promt the user to save the document (if possible, with
SaveAs name set to some I have pre-difined (="Rec Domectic Forecast -
"&summ!E3) to keep a standard naming convention.

Any ideas how this would be done? I can't seem to copy of the sheets since
the new workbook name changes (book(x)).

Thanks,
Rob


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
Print sheets by "All Sheets in workbook, EXCEPT for specific named sheets". Possible? Corey Excel Programming 2 December 11th 06 01:35 AM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork[_3_] Excel Programming 6 January 26th 06 06:31 PM


All times are GMT +1. The time now is 11:48 PM.

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"