ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a drop down list (https://www.excelbanter.com/excel-programming/324507-creating-drop-down-list.html)

Compnerd

Creating a drop down list
 
I need to create a drop down list, that when a user click on a selction it
will take the user to a certain worksheet in the workbook

Jim Thomlinson[_3_]

Creating a drop down list
 
I assume you know how to add a drop down list to a cell. Data - Validaton -
List (add the sheet names)

I am assuming that you are putting that drop down into Cell B2. You can
change this in the code pretty easily. Here is the code you want to add.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
If Target.Address = "$B$2" Then Sheets(Target.Value).Select

Exit Sub
ErrorHandler:
MsgBox "Sheet " & Target.Value & " does not exist. Please Try again",
vbCritical, "Sheet Error"
End Sub

Right click the tab with the drop down and select view code. Paste this code
in and you are off to the races...

HTH

"Compnerd" wrote:

I need to create a drop down list, that when a user click on a selction it
will take the user to a certain worksheet in the workbook


Compnerd

Creating a drop down list
 
I create a drop down list, but I cannot find tab to that says view code?

"Jim Thomlinson" wrote:

I assume you know how to add a drop down list to a cell. Data - Validaton -
List (add the sheet names)

I am assuming that you are putting that drop down into Cell B2. You can
change this in the code pretty easily. Here is the code you want to add.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
If Target.Address = "$B$2" Then Sheets(Target.Value).Select

Exit Sub
ErrorHandler:
MsgBox "Sheet " & Target.Value & " does not exist. Please Try again",
vbCritical, "Sheet Error"
End Sub

Right click the tab with the drop down and select view code. Paste this code
in and you are off to the races...

HTH

"Compnerd" wrote:

I need to create a drop down list, that when a user click on a selction it
will take the user to a certain worksheet in the workbook


Jim Thomlinson[_3_]

Creating a drop down list
 
Sorry about taking so long to get back to you. I was gone for lunch. There
are tabs at the bottom of the spreadsheet, which you can select to move from
sheet to sheet. If you right click on the tab you will get a menu allowing
you to Insert, Rename, Copy... The last item should be view code. If that
still is not working for you then you can go in through the VB Editor. Alt +
F11 is the quick way to get there. Once in the VBE on the left hand side you
should have a project explorer. double click the sheet you want and paste
the code...

HTH

"Compnerd" wrote:

I create a drop down list, but I cannot find tab to that says view code?

"Jim Thomlinson" wrote:

I assume you know how to add a drop down list to a cell. Data - Validaton -
List (add the sheet names)

I am assuming that you are putting that drop down into Cell B2. You can
change this in the code pretty easily. Here is the code you want to add.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
If Target.Address = "$B$2" Then Sheets(Target.Value).Select

Exit Sub
ErrorHandler:
MsgBox "Sheet " & Target.Value & " does not exist. Please Try again",
vbCritical, "Sheet Error"
End Sub

Right click the tab with the drop down and select view code. Paste this code
in and you are off to the races...

HTH

"Compnerd" wrote:

I need to create a drop down list, that when a user click on a selction it
will take the user to a certain worksheet in the workbook



All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com