• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select the Name in the Data Validation list on a cell value then the same name run the sub macro

Excel VBA code is required to Select the Name in the Data Validation list on a cell value after the same name could be run in the sub macro.

E.g. Data Validation List assigned in "Sheet3" cell text value "B2". if I select the "AA" and then Call to "AA" Sub Marco run. I got error the code line "Application.Run Text".

Below Excel VBA code here: Excel version is 2013

>>> use code - tag <<<

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    'Run Macro when Drop Down value selected
    'VBA to run from Data Validation
    'Auto Show Drop-Down List When Selecting the Cell
    If Target.CountLarge > 1 Then Exit Sub

    If Target.Address = Range("B2").Address Then
        Application.EnableEvents = False

        Dim Text As String
        Text = ThisWorkbook.Sheets("Sheet3").Range("B2").Value
        Application.Run Text

        'or

        'If Target.Address = "$A$1" Then
            'Call ThisWorkbook.Sheets("Sheet3").Range("B2").Value
        'End If
    End If

    Application.EnableEvents = True
End Sub


Public Sub AA()
    MsgBox "AA Macro"
End Sub


Public Sub BB()
    MsgBox "BB Macro"
End Sub


Public Sub CC()
    MsgBox "CC Macro"
End Sub

Thanks for Advance
Sivapraakasam K
 

Attachments

  • Sample.xlsm
    22 KB · Views: 2
Last edited by a moderator:

sivaprakasam

Have You read somewhere how to use Application.Run?

Instead of that, I would use something different - which works too.
( while testing Your file with Application.Run, I gotta reboot my Mac )
 

Attachments

  • Sample.xlsm
    16.9 KB · Views: 6
FYI, cross-posted:
 

sivaprakasam

You should reread Forum Rules ... from all Your used Forums:
  • Cross-Posting. Generally, it is considered poor practice to cross post. That is to post the same question on several forums in the hope of getting a response quicker.
  • If you do cross-post, please put that in your post.
  • Also if you have cross-posted and get an Solution elsewhere, have the courtesy of posting the Solution here so other readers can learn from the answer also, as well as stopping people wasting their time on your answered question.
 
O

sivaprakasam

You should reread Forum Rules ... from all Your used Forums:
  • Cross-Posting. Generally, it is considered poor practice to cross post. That is to post the same question on several forums in the hope of getting a response quicker.
  • If you do cross-post, please put that in your post.
  • Also if you have cross-posted and get an Solution elsewhere, have the courtesy of posting the Solution here so other readers can learn from the answer also, as well as stopping people wasting their time on your answered question.
Ohh okay
 
Back
Top