Forum

Select the Name in ...
 
Notifications
Clear all

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

3 Posts
3 Users
0 Reactions
186 Views
(@kpmsivaprakasam2003)
Posts: 15
Eminent Member
Topic starter
 

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

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

 
Posted : 02/09/2024 1:22 pm
(@keebellah)
Posts: 373
Reputable Member
 

Move the macro modules to a Module and run it again

 
Posted : 03/09/2024 1:37 am
(@debaser)
Posts: 837
Member Moderator
 

Cross-posted:

mrexcel.com/board/threads/select-the-name-in-the-data-validation-list-on-a-cell-value-then-the-same-name-run-the-sub-macro.1263786/

forum.ozgrid.com/forum/index.php?thread/1233791-select-the-name-in-the-data-validation-list-on-a-cell-value-then-the-same-name-r

chandoo.org/forum/threads/select-the-name-in-the-data-validation-list-on-a-cell-value-then-the-same-name-run-the-sub-macro.57649/

stackoverflow.com/questions/78937942/select-the-name-in-the-data-validation-list-on-a-cell-value-then-the-same-name-r

 
Posted : 03/09/2024 3:20 am
Share: