I have a worksheet with a large chart, and 6 buttons to navigate to different areas within the workbook. Each button also triggers various macros. I have more areas then I have room for buttons. I've attached a picture so you can see where I stand now. I have at least 4 more buttons I need to add, and would prefer a more elegant way to do it.
Is there a way to create some type of drop-down list I could put on the page, so the users could navigate to whatever sheet they need, and have that choice trigger the appropriate macros?
Thanks in advance for any ideas.
Last edited by jomili; 08-18-2011 at 11:28 AM.
Why not create a user form that pops up with multiple command buttons or links?
Use a data validation list with a worksheet change event linked to that cell.
You mean like a Navigation Console type of thing? That could work, but I'm thinking maybe instead using Data Validation, then using a Select Case statement of some sort in the Worksheet_Activate.
Bob,
Looks like our posts crossed. You and I are on the same wavelength. My Worksheet_Activate macro currently looks like this:E1 is where they select their region.Private Sub Worksheet_Change(ByVal Target As Range) Dim ws As Worksheet: Set ws = Sheets("View1Pivot") Dim ws2 As Worksheet: Set ws2 = Sheets("Chart-View 1") Application.ScreenUpdating = False If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$E$1" Then ws.Unprotect ws.AutoFilterMode = False ws.Range("N:N").AutoFilter Field:=1, Criteria1:=ws2.Range("E1").Text ws.Protect End If Application.ScreenUpdating = True End Sub
If I create a Data Validation in N1, with about 8 different options, how would I change this macro to handle all of that?
Okay, I've tried on my own, but it's not working. I've set up my Data Validation list in N1, but when I select, say "Go to View 1" (I'm on View 1) the message "There is nothing else" fires up. That message fires up no matter what I select. Any ideas?Private Sub Worksheet_Change(ByVal Target As Range) Dim ws As Worksheet: Set ws = Sheets("View1Pivot") Dim ws2 As Worksheet: Set ws2 = Sheets("Chart-View 1") Application.ScreenUpdating = False If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$E$1" Then ws.Unprotect ws.AutoFilterMode = False ws.Range("N:N").AutoFilter Field:=1, Criteria1:=ws2.Range("E1").Text ws.Protect End If If Target.Address = "$N$1" Then ws.Unprotect ws.AutoFilterMode = False Select Case LCase(Target.Value) Case "View the Details" Details Case "View Positions for this Area" ActivePosns Case "Go to View 1" MsgBox "You're currently looking at View 1" Case "Go to View 2" View2 Case "Go to View 3" View3 Case "Go to the Transferable PACs" MsgBox "we'll work out the code" Case Else MsgBox "There is nothing else!" End Select End If Application.ScreenUpdating = True End Sub
Hi jomili
Try changing this line of code fromtoSelect Case LCase(Target.Value)Select Case Target.Value
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Please read the VBA help on what lcase is doing
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub select case Target.address Case "$E$1","$N$1" with sheets("Chart-View 1") .Unprotect .AutoFilterMode = False if target.address="$E$1" then .columns(14).AutoFilter 1, .Range("E1").Text If Target.Address = "$N$1" Then Select Case LCase(Target.Value) Case "view the details" Details Case "view positions for this area" ActivePosns Case "go to view 1" MsgBox "You're currently looking at View 1" Case "go to view 2" View2 Case "go to view 3" View3 Case "go to the transferable pacs" MsgBox "we'll work out the code" Case Else MsgBox "There is nothing else!" End Select End If .Protect end with end select End Sub
Last edited by snb; 08-18-2011 at 11:24 AM.
Hmmm...,
SNB, I see what you mean. That's what I get from copying snippets of code from here and there.
Going with JasLake's suggestion, usingdoes the trick. Alternatively, puttingSelect Case Target.Valueat the top of the code module works also. But I think I'll just go with JasLake's suggestion.Option Compare Text
Thanks for all the help on this one!
John
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks