Notifications
Clear all

Executa Macro a partir de uma celula ativa

3 Posts
3 Usuários
0 Reactions
1,164 Visualizações
(@humberto)
Posts: 76
Estimable Member
Topic starter
 

gostaria de executar uma macro a partir de uma célula ativa.
EX: quando b2=1 então o Excel executa a macro selecionada
quando b2=2 então o Excel executa a macro selecionada
quando b2=3 então o Excel executa a macro selecionada...
e assim por diante.

 
Postado : 21/09/2012 8:45 pm
(@pexis)
Posts: 112
Estimable Member
 

Select Case sheets("plan1").range("B2").value
Case 1
macro1
Case 2
macro2
Case 3
macro3
End Select

 
Postado : 21/09/2012 9:01 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa noite!!

Vai ai uma gambiarra...

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Target = "" Then Exit Sub
    Application.ScreenUpdating = False
    Application.EnableEvents = False
     
   Select Case Sheets("Plan1").Range("B2").Value
    Case 1
    MsgBox "macro1"
    Case 2
    MsgBox "macro2"
    Case 3
    MsgBox "macro3"
    End Select
    Application.ScreenUpdating = True
    Application.EnableEvents = True
     
End Sub
 
Postado : 21/09/2012 9:21 pm