How do I create a worksheet using a drop down list?

G

Guest

Hi guys,

Is there any way to create a worksheet using a drop down list? For example,
if I had a drop down list consisting of M and B, selecting one of the two
values would create a worksheet with the name M with preassigned formulae and
values in the sheet?

Thanks
 
J

Joerg

The easiest way would be to prepare the 2 worksheets and hide them. Then
attach a simple unhide macro to your drop down list. If you really want to
create all sheet contents on-the-fly you would have to take additional
precautions so that another selection from your drop down list doesn't
overwrite an already existing sheet M with a fresh version.

Joerg
 
B

Bob Phillips

Try this, assuming the DV is in cell H1

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Worksheets.Add.Name = .Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top