Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert, name and format new worksheet

Hi,

I've an Excel Spreadsheet (Report) with n worksheets.
I'd like to create a VBA macro that, when I open the Spreadsheed:
a) asks if I want to add a new worksheet. If the answer is yes, then:
b) prompts a form to input the worksheet name
c) creates a new worksheet using the name inputed and positions the
worksheet as last
d) assigns a template (T_Z) to the worksheet

Alternatively steps c) and d) might be as well:

c) copies an existing worksheet Template_Z, renames it using the name
inputed and moves it to last place

Is this doable?

Thanks a lot!

G
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert, name and format new worksheet

I've not worked (code-wise) with Templates before, so I am not sure how to
implement your first option; however, I think the code below will address
your second option, assuming we are talking about a straight copy of a sheet
named Template_Z...

Private Sub Workbook_Open()
Dim Answer As Variant
Dim Answer2 As String
Dim WS As Worksheet
Answer = MsgBox("Do you want to add a new sheet?", _
vbQuestion Or vbYesNo, "New Sheet Question")
If Answer = vbYes Then
Answer = Trim(InputBox("What is new sheet's name?", "Get New Name"))
If Len(Answer) = 0 Then Exit Sub
For Each WS In Worksheets
If UCase(WS.Name) = UCase$(Answer) Then
Do
Answer2 = Trim(InputBox("Sorry, that name already exists, " & _
"chose another name.", "Duplicate Sheet Name"))
If Len(Answer2) = 0 Then Exit Sub
If UCase(Answer) < Trim(UCase(Answer2)) Then
Answer = Answer2
Exit For
End If
Loop
End If
Next
Worksheets("Template_Z").Copy After:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = Answer
End If
End Sub

Rick


"adjgiulio" wrote in message
...
Hi,

I've an Excel Spreadsheet (Report) with n worksheets.
I'd like to create a VBA macro that, when I open the Spreadsheed:
a) asks if I want to add a new worksheet. If the answer is yes, then:
b) prompts a form to input the worksheet name
c) creates a new worksheet using the name inputed and positions the
worksheet as last
d) assigns a template (T_Z) to the worksheet

Alternatively steps c) and d) might be as well:

c) copies an existing worksheet Template_Z, renames it using the name
inputed and moves it to last place

Is this doable?

Thanks a lot!

G


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert, name and format new worksheet

"Rick Rothstein (MVP - VB)" wrote in
message ...
however, I think the code below will address


Thanks!

G


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
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
Wish to add a WORKSHEET but 'WORKSHEET' not open in 'INSERT' Zona Excel Worksheet Functions 1 September 6th 06 03:52 AM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


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