Excel code to call a macro when a certain value in a cell isselected.

  • Thread starter Thread starter cemorganCO
  • Start date Start date
C

cemorganCO

I am trying to write code that will call a macro when the value of
cell is equal to a defined text.

Example:

If C28 = "Remind", then Call Macro_Name.

Can anyone help?

Thanks!
 
From Google:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value > 10 Then
MsgBox "Put your macro code here in place of the MsgBox line"
End If
End If
End Sub


Regards,
Ryan--
 
How does C28 get to be "Remind"?

I will assume a calculated formula.

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("C28")
If .Value = "remind" Then
Call Macroname
End If
End With
stoppit:
Application.EnableEvents = True
End Sub

The is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste into that module.


Gord Dibben MS Excel MVP
 
How does C28 get to be "Remind"?

I will assume a calculated formula.

Private Sub Worksheet_Calculate()
 On Error GoTo stoppit
   Application.EnableEvents = False
   With Me.Range("C28")
   If .Value = "remind" Then
           Call Macroname
 End If
End With
stoppit:
Application.EnableEvents = True
End Sub

The is sheet event code.  Right-click on the sheet tab and "View Code"

Copy/paste into that module.

Gord Dibben  MS Excel MVP







- Show quoted text -

Thanks Gord! That worked :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top