#1   Report Post  
Posted to microsoft.public.excel.programming
mc2 mc2 is offline
external usenet poster
 
Posts: 3
Default help

i have a workbook with a sheet in wich a cell, with data validation, can
display a serie of names; i.e., example1, example2, example3, ....

what i want is this:

if i select in that cell, for example, example1, then if sheet example1
exists it will be slected, otherwise it will be created with that name.

is this clear? i hope so :)

iŽll apreciate any solution, and ..., thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default help

Put the following code in the sheet module for the worksheet that
contains the cell with the validation:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address = "$A$1" Then
Worksheets(Target.Value).Select
If Err.Number < 0 Then
Worksheets.Add.Name = Target.Value
End If
End If
On Error GoTo 0
End Sub


Change $A$1 to the cell with the validation list.


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



"mc2" wrote in message
...
i have a workbook with a sheet in wich a cell, with data

validation, can
display a serie of names; i.e., example1, example2, example3,

.....

what i want is this:

if i select in that cell, for example, example1, then if sheet

example1
exists it will be slected, otherwise it will be created with

that name.

is this clear? i hope so :)

iŽll apreciate any solution, and ..., thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
mc2 mc2 is offline
external usenet poster
 
Posts: 3
Default help

hi, thanks, it works great!

can you change the code to do the same but instead of adding a new sheet, it
will duplicate an existing one, and the duplicated will have the name that
is in the cell with the validation.
i hope iŽm clear :)

"Chip Pearson" wrote in message
...
Put the following code in the sheet module for the worksheet that
contains the cell with the validation:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address = "$A$1" Then
Worksheets(Target.Value).Select
If Err.Number < 0 Then
Worksheets.Add.Name = Target.Value
End If
End If
On Error GoTo 0
End Sub


Change $A$1 to the cell with the validation list.


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



"mc2" wrote in message
...
i have a workbook with a sheet in wich a cell, with data

validation, can
display a serie of names; i.e., example1, example2, example3,

....

what i want is this:

if i select in that cell, for example, example1, then if sheet

example1
exists it will be slected, otherwise it will be created with

that name.

is this clear? i hope so :)

iŽll apreciate any solution, and ..., thanks in advance.






  #4   Report Post  
Posted to microsoft.public.excel.programming
mc2 mc2 is offline
external usenet poster
 
Posts: 3
Default help

Thanks Abdul Salam!

Dont work :)

i want duplicate one sheet, with all the things, ... formats ....



"Abdul Salam" wrote in message
...
Modify code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address = "$A$1" Then
Worksheets(Target.Value).Select
If Err.Number < 0 Then
Sheet2.Select ' change to your name
Cells.Select
Selection.Copy
Worksheets.Add.Name = Target.Value
Selection.PasteSpecial Paste:=xlPasteAll
Range("A1").Select
End If
End If
On Error GoTo 0
End Sub


Abdul Salam
-----Original Message-----
hi, thanks, it works great!

can you change the code to do the same but instead of

adding a new sheet, it
will duplicate an existing one, and the duplicated will

have the name that
is in the cell with the validation.
i hope iŽm clear :)

"Chip Pearson" wrote in message
...
Put the following code in the sheet module for the

worksheet that
contains the cell with the validation:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address = "$A$1" Then
Worksheets(Target.Value).Select
If Err.Number < 0 Then
Worksheets.Add.Name = Target.Value
End If
End If
On Error GoTo 0
End Sub


Change $A$1 to the cell with the validation list.


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



"mc2" wrote in message
...
i have a workbook with a sheet in wich a cell, with

data
validation, can
display a serie of names; i.e., example1, example2,

example3,
....

what i want is this:

if i select in that cell, for example, example1,

then if sheet
example1
exists it will be slected, otherwise it will be

created with
that name.

is this clear? i hope so :)

iŽll apreciate any solution, and ..., thanks in

advance.







.




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



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

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

About Us

"It's about Microsoft Excel"