PC Review


Reply
Thread Tools Rate Thread

create worksheet with specific name

 
 
Vladimir
Guest
Posts: n/a
 
      6th Dec 2008
The workbook has already 4 worksheets: Plan and 3 reports.
In the first worksheet (plan) with a toolbox combobox the user will choose 1
of 4 options:
Jan-feb-march
apr-may-june
july-aug-sept
oct-nov-dec

when 1 of 4 options is choosen automatically other 3 worksheets shoud
receive respective names: say apr, may, june and in a cell of each worksheet
should appear April, May or June correspondingly.

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      6th Dec 2008
MonthSelected = combobox1.Value

For Each sht In Sheets
If UCase(sht.Name) <> "PLAN" Then

'test if there is a dash in sht names
If InStr(MonthSelected, "-") > 0 Then
Mnth = Left(MonthSelected, _
InStr(MonthSelected, "-") - 1)
sht.Name = Mnth
MonthSelected = Mid(MonthSelected, _
InStr(MonthSelected, "-") + 1)
Else
sht.Name = MonthSelected
Exit For
End If
End If
Next sht


"Vladimir" wrote:

> The workbook has already 4 worksheets: Plan and 3 reports.
> In the first worksheet (plan) with a toolbox combobox the user will choose 1
> of 4 options:
> Jan-feb-march
> apr-may-june
> july-aug-sept
> oct-nov-dec
>
> when 1 of 4 options is choosen automatically other 3 worksheets shoud
> receive respective names: say apr, may, june and in a cell of each worksheet
> should appear April, May or June correspondingly.
>

 
Reply With Quote
 
AndrewCerritos
Guest
Posts: n/a
 
      6th Dec 2008
Hi, is this what you need?
1) this sub will be called when user select something in the ComboBox
2) the value is parsed, separated by "-"
3) active sheet is the PLAN sheet: move it to the first
4) name the rest of sheets by month name
5) also put month name to cell [A1] in corresponding sheet
If full name is needed (i.e. April instead of apr), can add simple
translation routine to do it.

Private Sub ComboBox1_Change()
Dim strQTR As String

strQTR = ComboBox1.Value
ActiveSheet.Move before:=Worksheets(1) ' move PLAN as 1st sheet
Worksheets(2).Name = Split(strQTR, "-")(0) ' 1st month
Worksheets(3).Name = Split(strQTR, "-")(1) ' 2nd month
Worksheets(4).Name = Split(strQTR, "-")(2) ' 3rd month
Worksheets(2).[A1] = Worksheets(2).Name ' cell [A1] has the name
Worksheets(3).[A1] = Worksheets(3).Name
Worksheets(4).[A1] = Worksheets(4).Name
End Sub

--AC


"Joel" wrote:

> MonthSelected = combobox1.Value
>
> For Each sht In Sheets
> If UCase(sht.Name) <> "PLAN" Then
>
> 'test if there is a dash in sht names
> If InStr(MonthSelected, "-") > 0 Then
> Mnth = Left(MonthSelected, _
> InStr(MonthSelected, "-") - 1)
> sht.Name = Mnth
> MonthSelected = Mid(MonthSelected, _
> InStr(MonthSelected, "-") + 1)
> Else
> sht.Name = MonthSelected
> Exit For
> End If
> End If
> Next sht
>
>
> "Vladimir" wrote:
>
> > The workbook has already 4 worksheets: Plan and 3 reports.
> > In the first worksheet (plan) with a toolbox combobox the user will choose 1
> > of 4 options:
> > Jan-feb-march
> > apr-may-june
> > july-aug-sept
> > oct-nov-dec
> >
> > when 1 of 4 options is choosen automatically other 3 worksheets shoud
> > receive respective names: say apr, may, june and in a cell of each worksheet
> > should appear April, May or June correspondingly.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a Link to a Specific Worksheet mlenmik Microsoft Excel Misc 2 16th Jun 2009 04:32 PM
Create a new worksheet with a macro and giving it a specific name Steve Krieger Microsoft Excel Misc 4 27th May 2009 10:18 PM
Create a new worksheet with a macro and giving it a specific name Steve Krieger Microsoft Excel Misc 0 27th May 2009 09:48 PM
How do you create a menu for just that specific worksheet? =?Utf-8?B?Z3JlZ2VzYXU=?= Microsoft Excel Misc 1 1st Jan 2007 01:18 AM
create named range specific to worksheet beliavsky@aol.com Microsoft Excel Programming 2 28th Jun 2005 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 AM.