+ Reply to Thread
Results 1 to 8 of 8

Run Macros from Multiple Drop down lists in same sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    09-10-2007
    Posts
    40

    Run Macros from Multiple Drop down lists in same sheet

    Hi there,

    I would like to be able to run different Macros from about 4 different drop down lists in one single sheet. I am using the following code to run from a single drop down list.
     
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$7" Then
            If Target = "30" Then
                T_30
    How can I run more macros from other drop down lists located in other cells in the same sheet.

    Any help on this issue would be greatly appreciated,

    Regards,

    James.
    Last edited by VBA Noob; 10-04-2007 at 07:40 AM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi James,

    You can hopefully try a Select Case routine, such as the example provided below:
    Private Sub Worksheet_Change(ByVal Target As Range)
        Select Case Target.Address
            Case Is = "$A$1"
                MsgBox "Cell A1!"
            Case Is = "$A$2"
                MsgBox "Cell A2!"
            Case Is = "$A$3"
                MsgBox "Cell A3!"
            Case Else
                MsgBox "Woops!"
        End Select
    End Sub
    Change the cells to your cell references and replace the MsgBox's with your code. You can have as many Case statements as you need, and you should typically use a Case Else as your last statement just in case the rest don't return a result.

  3. #3
    Registered User
    Join Date
    09-10-2007
    Posts
    40
    Thanks for the reply. There was no such luck with that solution.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    "No such luck.." doesn't give any of us a clue as to WHY my suggestion didn't work. Please either give more details or post a copy of your spreadsheet (must be zipped first) and let us know exactly what you're attempting to do.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi Thanks for your help so far, it is much appreciated.

    I am working with an array of data that can be filtered by many columns and criteria. What I need to do is be able to select from a drop down list and run and macro based on a selection.

    I can do this fine if I only run one drop down list per page. The problem I am having is working out how to use 2 or more drop down lists and select an option from it and run a macro to filter the results.

    At present I am using this code

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$7" Then
    If Target = "30" Then
    T_30

    but as you can see this only refers to A7. What I need is the ability to have other cells which contain drop down lists to be part and have the ability to activate a macro.

    I did try your code, and your instructions and it doesn't attempt to execute the macro.

    If you have any ideas of, I would be fond to hear of them.

    Many Thanks,

    James
    Seeing as it's now 11:30pm and I have to get some sleep before meetings in the morning, perhaps someone in another time zone can assist you with this for now. Thanks for providing more information.

  6. #6
    Registered User
    Join Date
    09-10-2007
    Posts
    40
    Does anyone have any ideas on this. I will give $30USD to whoever finds me a working solution. .Cheers..

+ 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.6.0 RC 1