View Single Post
  #10   Report Post  
Norman Jones
 
Posts: n/a
Default How do I execute a macro based on the value of a cell in Excel?

Hi Ltat42a,

To avoid posible confusion

Change A1 to the cell of interest.


was intended to refer to both of the lines:

If Not Intersect(Target, Range("A1")) Is Nothing Then
Select Case Range("A1").Value '<<=== CHANGE


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Ltat42a,

Oooppps. I should have explained better. I want to get rid of the
images I use to run the macros. When a user inserts an "A" into a
particular cell, it will run the "A" macro that I created, when someone
enters "B", it runs the "B" macro...etc...etc...


In that case, try:
'===============
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1")) Is Nothing Then
Select Case Range("A1").Value '<<=== CHANGE
Case "A"
Macro1
Case "B"
Macro2
Case "C"
Macro3
End Select
End If

End Sub
'<<===============

This is worksheet event code and should be pasted into the worksheets's
code module (not a standard module and not the workbook's ThisWorkbook
module):

*******************************************
Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.
*******************************************


Change A1 to the cell of interest.

---
Regards,
Norman