+ Reply to Thread
Results 1 to 7 of 7

not able to "call" a macro.

Hybrid View

  1. #1
    Registered User
    Join Date
    08-05-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    45

    not able to "call" a macro.

    I have five different macros that run depending on what cell is selected. They are linked to a text box. However; I am trying to get the macros to run depending on one cell whose value is chosen from a drop down menu. Looking around for a solution, it appears that the code should be like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address(False, False) = "j7" Then
    
            Select Case Target.Value
            
            Case 1
                Call addday1
            
            Case 2
                Call addday2
            
            Case 3
                Call addday3
                
                            
            End Select
            
        End If
    End Sub
    But I am missing something because this is not working. This doesn’t run any of the macros no matter what is selected in the dropdown menu in cell j7. What am I leaving out?

    Thanks.
    Last edited by VectorW2; 08-05-2013 at 05:58 PM. Reason: does not comply with rule #3

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: not able to "call" a macro.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    HTH
    Regards, Jeff

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: not able to "call" a macro.

    What is in J7?

  4. #4
    Registered User
    Join Date
    08-05-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: not able to "call" a macro.

    it is currently blank; the options are from drop down are nothing, 1, 2, 3, 4, 5.

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: not able to "call" a macro.

    I see nothing wrong with the macro, but also, I ran it on a test and it runs fine.

    Did you place the macro in the sheet module and not in a regular module?

  6. #6
    Registered User
    Join Date
    08-05-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: not able to "call" a macro.

    maybe that is the issue. How do I check and see if this is the issue and do that if it is?

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: not able to "call" a macro.

    Hi VectorW2

    Jeff asked me to follow up on this...

    Place this Code in the Worksheet Module of the Worksheet your monitoring.

    Copy the Code
    Right Click on the Subject Tab
    Select "View Code"
    Paste the Code in the Right Hand Window.
    Get out of VBA (Alt + F11)

    Select an item from the DropDown in Cell J7...the Code will fire.
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
        If Target.Address = "$J$7" Then
           Select Case Target.Value
            Case 1
                Call addday1
            Case 2
                Call addday2
            Case 3
                Call addday3
            Case 4
                Call addday4
            Case 5
                Call addday5
            Case Else
                'Do Nothing or your Code here
            End Select
        End If
    End Sub
    See attached...
    Attached Files Attached Files
    Last edited by jaslake; 08-05-2013 at 05:56 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. [SOLVED] Call "another Macro" multiple times
    By Simon.Ward in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2013, 08:03 AM
  3. [SOLVED] How do I call "My Computer" in a macro?
    By jlax34 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2012, 11:28 AM
  4. Macro that simulates a "call ticker" for sales
    By hysterical.useless in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2012, 12:34 AM
  5. Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo
    By QC Coug in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2005, 03:05 PM

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