+ Reply to Thread
Results 1 to 9 of 9

Thread: Alternative to buttons needed

  1. #1
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Alternative to buttons needed

    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.
    Attached Images Attached Images
    Last edited by jomili; 08-18-2011 at 11:28 AM.

  2. #2
    Forum Guru
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    1,798

    Re: Alternative to buttons needed

    Why not create a user form that pops up with multiple command buttons or links?

  3. #3
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Alternative to buttons needed

    Use a data validation list with a worksheet change event linked to that cell.

  4. #4
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Alternative to buttons needed

    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.

  5. #5
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Alternative to buttons needed

    Bob,

    Looks like our posts crossed. You and I are on the same wavelength. My Worksheet_Activate macro currently looks like this:
    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
    E1 is where they select their region.
    If I create a Data Validation in N1, with about 8 different options, how would I change this macro to handle all of that?

  6. #6
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Alternative to buttons needed

    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

  7. #7
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    mineral city, ohio
    MS-Off Ver
    Excel 2007; Excel 2000
    Posts
    4,004

    Re: Alternative to buttons needed

    Hi jomili

    Try changing this line of code from
    Select Case LCase(Target.Value)
    to
    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.

  8. #8
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Alternative to buttons needed

    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.



  9. #9
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Alternative to buttons needed

    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, using
    Select Case Target.Value
    does the trick. Alternatively, putting
    Option Compare Text
    at the top of the code module works also. But I think I'll just go with JasLake's suggestion.

    Thanks for all the help on this one!

    John

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0