How to activate a macro by a word in a specific cell

Copper Contributor

1st time user of macro!

2 Replies
This doesn't make sense to me. Typically a macro will be activated by the user through the menus, or using a button or may run automatically. The automatic is based on an event like opening the workbook or making a change on the worksheet. One needs to be careful with the automatic type as it can really slow down a workbook performance.
So in answer to your question it can be done that if someone types a particular word in a specific cell a macro that runs on any change in the sheet could detect that and then execute a particular set of command and as part of those commands I assume you will erase that word (so it doesn't go in an infinite loop).
To do that you need to create an _onchange macro on the specific sheet it will be monitoring.


So I don't know any way right away how you could do this, I'm not sure if this is possible at all.

But here is a link with a code for Run Macro Based On Cell Value maybe it will help you further in your project.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If IsNumeric(Target) And Target.Address = "$A$1" Then
        Select Case Target.Value
        Case 10 To 50: Macro1
        Case Is > 50: Macro2
        End Select
    End If
End Sub


Hope I could help you with these information / links.



I know I don't know anything (Socrates)