+ Reply to Thread
Results 1 to 3 of 3

How to run a macro for each item in dropdown?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2014
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    77

    How to run a macro for each item in dropdown?

    Hi,

    I've created a dropdown list using "Data Validation" containing 5 items.

    Each item in dropdown should run a macro when selected.

    Should i use worksheet selection change event? or anything else



    Thank you

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to run a macro for each item in dropdown?

    Use the worksheet Change event

    Typically

    If Not Intersect (Target, Range("yourdropdowncell")) Is Nothing Then
     
       Select Case Target  
          Case = 1 'change to refelect what your actual drop down returns
             'your macro for dropdown "1" value
    
          Case = 2 
             'your macro for dropdown "2" value
    
    '...etc...
    
       End Select
    End If
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    01-12-2014
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    77

    Re: How to run a macro for each item in dropdown?

    Hi,

    I've tried the following code and is doing nothing. Actually the dropdown has items-Three months, Six months, One year.
    Can you please tell what changes should me made to get the code work.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("H14")) Is Nothing Then
     
       Select Case Target
          Case Is = 1 'One year
             'Call calcfor12
    
    
          Case Is = 2 'Six months
             'Call calcfor6
             
          Case Is = 3 'Three months
            'Call calcfor3
    
    
       End Select
    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using VBA to Select Dropdown Item
    By Ric_W in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2013, 02:12 PM
  2. use dropdown and show another item automatically
    By mtsf in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-14-2013, 03:06 AM
  3. macro to unhide row when a dropdown list item is selected
    By ahng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2012, 07:17 AM
  4. [SOLVED] How To? Cells Always Fill With Certain Item from Dropdown
    By Brenna in forum Excel General
    Replies: 4
    Last Post: 11-15-2012, 11:12 PM
  5. [SOLVED] Unable to run macro on every dropdown item
    By Datcy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-24-2012, 02:53 AM

Tags for this Thread

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