Can you enter a formula in a cell to run a macro?

N

Nevaeh

Is there a way where I can enter a formula to run a macro? For example could
I enter a formula that say "if this value is greater than or equal to run
this macro".
 
G

Gord Dibben

A formula cannot run a macro.

Event code behind the worksheet could be used to run a macro when a cell
reaches a specific value.

Private Sub Worksheet_Calculate()
On Error GoTo enditall
Application.EnableEvents = False
If Range("$B$3").Value >= 123 Then
ListColorIndexes
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on a sheet tab and "View Code"

Copy/paste the above in there.


Gord Dibben Excel MVP
 
G

Gord Dibben

Jeez.........having a bad day.

"ListColorIndexes" will of course be adjusted to your macroname.


Gord
 

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

Top