Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Hi,

Can someone help me with some compact code that will:

- create a new workbook
- Name the workbook based on a 5 letter variable + month & year from a
variable. Ex. ABCDE 05-2005.xls
- Add 4 Sheets
- Name each sheet

I am working on copying data from a tool to be sent to users. I have
the copy and e-mail code working right, just need help with setting up
the blank workbook.

Much thanks,

Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Try something like the following:

Dim WB As Workbook
Dim SaveSINW As Integer
Application.ScreenUpdating = False
SaveSINW = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 4
Set WB = Workbooks.Add
Application.SheetsInNewWorkbook = SaveSINW
WB.SaveAs "ABCDF" & Format(Now, "mm-yyyy") & ".xls"
WB.Sheets(1).Name = "First Name "
WB.Sheets(2).Name = "Second Name "
WB.Sheets(3).Name = "Third Name "
WB.Sheets(4).Name = "Fourth Name "
Application.ScreenUpdating = True



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in message
oups.com...
Hi,

Can someone help me with some compact code that will:

- create a new workbook
- Name the workbook based on a 5 letter variable + month & year
from a
variable. Ex. ABCDE 05-2005.xls
- Add 4 Sheets
- Name each sheet

I am working on copying data from a tool to be sent to users.
I have
the copy and e-mail code working right, just need help with
setting up
the blank workbook.

Much thanks,

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Thanks guys,

Dick,
Your solution is nice and simple, but the end user will be utilizing
the code. I can't send a templet to all of them.

Chip,
Two questions:

1 - I have the date saved in a cell on a specific worksheet, can you
suggest a siple way to reference within your line that does the saveas?

2 - I don't want to leave a trace on the hard drive. Does the save as
put the file in the default directory set in the users excel options?
How would I delete after my send via e-mail code runs.

MUCH MUCH Thanks for the help,

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Chip,

I have played around with the code and did get question number 1
answered.

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Ok - next time I will play with the code before asking follow up
questions.

I found that setting a variable to the new workbook name and the
running "Kill (name)" seems to work.

Are there any issues with that command and format?

Cheers,

Greg



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Greg wrote:
Ok - next time I will play with the code before asking follow up
questions.

I found that setting a variable to the new workbook name and the
running "Kill (name)" seems to work.

Are there any issues with that command and format?


It's super dangerous if you don't know what you're doing, because it really
deletes instead of sending to the recycle bin. It sounds like you know what
you're doing, so you should have no problem using it.


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Create New Workbook - Name book - 4 Sheets - Name Sheets

Greg

Create a template with four sheets named how you want. Name it MyTemplate.
Then:

Dim wb as Workbook
Dim sFiveLetter as String
Dim dVariable as Date

sFiveLetter = "ABCDE"
dVariable = #05/01/2005#

Set wb = Workbooks.Add("MyTemplate.xlt")
wb.SaveAs sFiveLetter & " " & Format(dVariable, "mm-yyyy") & ".xls"


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Greg wrote:
Hi,

Can someone help me with some compact code that will:

- create a new workbook
- Name the workbook based on a 5 letter variable + month & year from a
variable. Ex. ABCDE 05-2005.xls
- Add 4 Sheets
- Name each sheet

I am working on copying data from a tool to be sent to users. I have
the copy and e-mail code working right, just need help with setting up
the blank workbook.

Much thanks,

Greg



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
how do I create a quick directory of sheets in workbook Momturbo Excel Discussion (Misc queries) 2 December 11th 08 09:28 PM
Macro to create new workbook and sheets Richard Excel Discussion (Misc queries) 1 July 31st 07 07:31 PM
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 create workbook with multiple sheets control freak Excel Discussion (Misc queries) 0 July 19th 06 06:54 PM
VBA to create an Array of all Sheets in workbook Guy Hoffman[_3_] Excel Programming 3 January 13th 04 03:50 AM


All times are GMT +1. The time now is 12:41 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"