How can I embed a macro into a function in excel?

D

Don

I'm trying to create a logical "if" statment that will turn a cell one color
or another depending on what is in another cell. How does one insert/trigger
a macro in a function?
 
J

JE McGimpsey

Try using Conditional Formatting instead.

Select A1. Choose Format/Conditional Formatting. Enter

CF1: Formula is =A2>10
Format1: Patterns/Red

Click OK.

Now when you enter a value > 10 in A2, cell A1 turns red.

If you need more than 3 conditional colors, you'll have to use an event
macro, such as a Worksheet_Calculate or Worksheet_Change:

http://cpearson.com/excel/events.htm
 
G

Gord Dibben

Don

Investigate the use of Format>Conditional Formatting. Allows 3 conditions(4
if you count the default)

You could use the Formula is:

e.g.

condition 1 =A1="qwerty" format to blue color.

Add and condition 2 =A1>123 format to red color.

Add and condition 3 =A1=123 format to green color.

Functions cannot call macros.


Gord Dibben Excel MVP
 

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