drop down lists

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,602
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a drop down list which contains aprox 15 items, I want the user to be able to select an item from that list and then a certain worksheet be opened relating to that list.

So if Apple is select from the list - sheet 1 is opened
if Orange is selcted from the list - sheet 2 is opened
...and so on

can anybody provide some code for a novice

Many thanks in advance
 
Dufus

The code posted earlier....

Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
Dim myWs As String, ws As Workbook 
With Target 
   If .Address(0,0) <>"F27" Then Exit Sub 
   If .Value = "" Then Exit Sub 
   On Error Resume Next 
   Set ws = Sheets(.Text) 
   On Error GoTo 0 
   If Not ws Is Nothing Then 
      ws.Activate 
   Else 
      MsgBox .Value & " Sheet doesn't exist" 
   End If 
End  With 
End Sub

Kind of worked, however the response to every item selected from the menu was "xxxx Sheet doesn't exsist"
when clearly it did.

Now I'm realy confused ! - hope you can help
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The code I meant was:

Code:
Sub test() 
Dim i As Integer 
With Range("U1") 
     For i = 1 To Sheets.Count 
         .Offset(i-1).Value = Sheets(i).Name 
     Next 
End With 
End Sub

Run it and copy paste the results.
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
With Target 
   If .Address(0,0) <>"F27" Then Exit Sub 
   If .Value = "" Then Exit Sub 
   On Error GoTo Last 
   Sheets(.Text).Activate
   Exit Sub
Last: 
      MsgBox .Value & " Sheet doesn't exist" 
End  With 
End Sub
 
Upvote 0
results as shown are :

test
Sheet2
SEP06
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
 
Upvote 0
Jindon


this code


Code:
Private Sub Worksheet_Change(ByVal Target As Range) 
With Target 
   If .Address(0,0) <>"F27" Then Exit Sub 
   If .Value = "" Then Exit Sub 
   On Error GoTo Last 
   Sheets(.Text).Activate 
   Exit Sub 
Last: 
      MsgBox .Value & " Sheet doesn't exist" 
End  With 
End Sub

did the trick..



YIPPPPPPEEEEEEE !!!!!!!!!!!!!!!!!


Thanks so much for all your patience with me on this
 
Upvote 0

Forum statistics

Threads
1,215,700
Messages
6,126,305
Members
449,308
Latest member
VerifiedBleachersAttendee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top